aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-11 01:50:13 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-11 01:50:13 +0800
commit617804c32731c5103319e7072557f62a9ce63836 (patch)
treebaca8a8f2e014892983ca45e8ec618ab54121526 /cmd/utils
parent3de51f76eea87f8e8a4b8a7277cd294529e28491 (diff)
parentbbe8b186600992ada6da9e75e9976cd5a9dc0ae3 (diff)
downloadgo-tangerine-617804c32731c5103319e7072557f62a9ce63836.tar
go-tangerine-617804c32731c5103319e7072557f62a9ce63836.tar.gz
go-tangerine-617804c32731c5103319e7072557f62a9ce63836.tar.bz2
go-tangerine-617804c32731c5103319e7072557f62a9ce63836.tar.lz
go-tangerine-617804c32731c5103319e7072557f62a9ce63836.tar.xz
go-tangerine-617804c32731c5103319e7072557f62a9ce63836.tar.zst
go-tangerine-617804c32731c5103319e7072557f62a9ce63836.zip
Merge branch 'rpcfrontier' of github.com:ethereum/go-ethereum into rpcfrontier
Diffstat (limited to 'cmd/utils')
-rw-r--r--cmd/utils/cmd.go50
1 files changed, 26 insertions, 24 deletions
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index a77c6ad4d..a7e609af7 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -35,7 +35,6 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/rlp"
rpchttp "github.com/ethereum/go-ethereum/rpc/http"
- "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/xeth"
)
@@ -134,6 +133,15 @@ func StartEthereum(ethereum *eth.Ethereum) {
})
}
+func StartEthereumForTest(ethereum *eth.Ethereum) {
+ clilogger.Infoln("Starting ", ethereum.Name())
+ ethereum.StartForTest()
+ RegisterInterrupt(func(sig os.Signal) {
+ ethereum.Stop()
+ logger.Flush()
+ })
+}
+
func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, SecretFile string, ExportDir string, NonInteractive bool) {
var err error
switch {
@@ -188,27 +196,8 @@ func FormatTransactionData(data string) []byte {
return d
}
-// Replay block
-func BlockDo(ethereum *eth.Ethereum, hash []byte) error {
- block := ethereum.ChainManager().GetBlock(hash)
- if block == nil {
- return fmt.Errorf("unknown block %x", hash)
- }
-
- parent := ethereum.ChainManager().GetBlock(block.ParentHash())
-
- statedb := state.New(parent.Root(), ethereum.StateDb())
- _, err := ethereum.BlockProcessor().TransitionState(statedb, parent, block, true)
- if err != nil {
- return err
- }
-
- return nil
-
-}
-
-func ImportChain(chain *core.ChainManager, fn string) error {
- fmt.Printf("importing chain '%s'\n", fn)
+func ImportChain(chainmgr *core.ChainManager, fn string) error {
+ fmt.Printf("importing blockchain '%s'\n", fn)
fh, err := os.OpenFile(fn, os.O_RDONLY, os.ModePerm)
if err != nil {
return err
@@ -220,11 +209,24 @@ func ImportChain(chain *core.ChainManager, fn string) error {
return err
}
- chain.Reset()
- if err := chain.InsertChain(blocks); err != nil {
+ chainmgr.Reset()
+ if err := chainmgr.InsertChain(blocks); err != nil {
return err
}
fmt.Printf("imported %d blocks\n", len(blocks))
return nil
}
+
+func ExportChain(chainmgr *core.ChainManager, fn string) error {
+ fmt.Printf("exporting blockchain '%s'\n", fn)
+
+ data := chainmgr.Export()
+
+ if err := ethutil.WriteFile(fn, data); err != nil {
+ return err
+ }
+ fmt.Printf("exported blockchain\n")
+
+ return nil
+}