Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
1054c155
Commit
1054c155
authored
Dec 23, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved import to utils
parent
7d2353f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
main.go
cmd/ethereum/main.go
+2
-18
cmd.go
cmd/utils/cmd.go
+24
-0
No files found.
cmd/ethereum/main.go
View file @
1054c155
...
...
@@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/rlp"
)
const
(
...
...
@@ -118,26 +117,11 @@ func main() {
}
if
len
(
ImportChain
)
>
0
{
clilogger
.
Infof
(
"importing chain '%s'
\n
"
,
ImportChain
)
fh
,
err
:=
os
.
OpenFile
(
ImportChain
,
os
.
O_RDONLY
,
os
.
ModePerm
)
err
:=
utils
.
ImportChain
(
ethereum
,
ImportChain
)
if
err
!=
nil
{
clilogger
.
Infoln
(
err
)
return
}
defer
fh
.
Close
()
var
chain
types
.
Blocks
if
err
:=
rlp
.
Decode
(
fh
,
&
chain
);
err
!=
nil
{
clilogger
.
Infoln
(
err
)
return
}
ethereum
.
ChainManager
()
.
Reset
()
if
err
:=
ethereum
.
ChainManager
()
.
InsertChain
(
chain
);
err
!=
nil
{
clilogger
.
Infoln
(
err
)
return
}
clilogger
.
Infof
(
"imported %d blocks
\n
"
,
len
(
chain
))
return
}
// better reworked as cases
...
...
cmd/utils/cmd.go
View file @
1054c155
...
...
@@ -13,6 +13,7 @@ import (
"runtime"
"bitbucket.org/kardianos/osext"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
...
...
@@ -20,6 +21,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/xeth"
)
...
...
@@ -335,3 +337,25 @@ func BlockDo(ethereum *eth.Ethereum, hash []byte) error {
return
nil
}
func
ImportChain
(
ethereum
*
eth
.
Ethereum
,
fn
string
)
error
{
clilogger
.
Infof
(
"importing chain '%s'
\n
"
,
ImportChain
)
fh
,
err
:=
os
.
OpenFile
(
fn
,
os
.
O_RDONLY
,
os
.
ModePerm
)
if
err
!=
nil
{
return
err
}
defer
fh
.
Close
()
var
chain
types
.
Blocks
if
err
:=
rlp
.
Decode
(
fh
,
&
chain
);
err
!=
nil
{
return
err
}
ethereum
.
ChainManager
()
.
Reset
()
if
err
:=
ethereum
.
ChainManager
()
.
InsertChain
(
chain
);
err
!=
nil
{
return
err
}
clilogger
.
Infof
(
"imported %d blocks
\n
"
,
len
(
chain
))
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment