diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-23 22:37:03 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-23 22:37:03 +0800 |
commit | 1054c155db8ac59b97b81fa7a7a20f2239eb1e82 (patch) | |
tree | b826dff6b28b9daaf585f1db8f30309117f882d0 /cmd/utils/cmd.go | |
parent | 7d2353f24dad8bba8914b4014117fe73248c211c (diff) | |
download | go-tangerine-1054c155db8ac59b97b81fa7a7a20f2239eb1e82.tar go-tangerine-1054c155db8ac59b97b81fa7a7a20f2239eb1e82.tar.gz go-tangerine-1054c155db8ac59b97b81fa7a7a20f2239eb1e82.tar.bz2 go-tangerine-1054c155db8ac59b97b81fa7a7a20f2239eb1e82.tar.lz go-tangerine-1054c155db8ac59b97b81fa7a7a20f2239eb1e82.tar.xz go-tangerine-1054c155db8ac59b97b81fa7a7a20f2239eb1e82.tar.zst go-tangerine-1054c155db8ac59b97b81fa7a7a20f2239eb1e82.zip |
Moved import to utils
Diffstat (limited to 'cmd/utils/cmd.go')
-rw-r--r-- | cmd/utils/cmd.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 2b24ac532..c0a5d1c97 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -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 +} |