aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-10-06 22:35:55 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-10-16 08:22:06 +0800
commit1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8 (patch)
treefefd9cfe28ce5b409d58c70b03cf4a6d6dc84873 /cmd
parentf466243417f60531998e8b500f2bb043af5b3d2a (diff)
downloaddexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar
dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.gz
dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.bz2
dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.lz
dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.xz
dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.zst
dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.zip
core/state, core, miner: handle missing root error from state.New
Diffstat (limited to 'cmd')
-rw-r--r--cmd/evm/main.go2
-rw-r--r--cmd/geth/blocktestcmd.go10
-rw-r--r--cmd/geth/chaincmd.go6
3 files changed, 13 insertions, 5 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
index e170dc190..64044c421 100644
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -113,7 +113,7 @@ func run(ctx *cli.Context) {
glog.SetV(ctx.GlobalInt(VerbosityFlag.Name))
db, _ := ethdb.NewMemDatabase()
- statedb := state.New(common.Hash{}, db)
+ statedb, _ := state.New(common.Hash{}, db)
sender := statedb.CreateAccount(common.StringToAddress("sender"))
receiver := statedb.CreateAccount(common.StringToAddress("receiver"))
receiver.SetCode(common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name)))
diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go
index e0a5becdc..e4d97aa53 100644
--- a/cmd/geth/blocktestcmd.go
+++ b/cmd/geth/blocktestcmd.go
@@ -101,7 +101,8 @@ func runBlockTest(ctx *cli.Context) {
func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, error) {
cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx)
- cfg.NewDB = func(path string) (ethdb.Database, error) { return ethdb.NewMemDatabase() }
+ db, _ := ethdb.NewMemDatabase()
+ cfg.NewDB = func(path string) (ethdb.Database, error) { return db, nil }
cfg.MaxPeers = 0 // disable network
cfg.Shh = false // disable whisper
cfg.NAT = nil // disable port mapping
@@ -113,7 +114,7 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er
// import the genesis block
ethereum.ResetWithGenesisBlock(test.Genesis)
// import pre accounts
- _, err = test.InsertPreState(ethereum)
+ _, err = test.InsertPreState(db, cfg.AccountManager)
if err != nil {
return ethereum, fmt.Errorf("InsertPreState: %v", err)
}
@@ -123,7 +124,10 @@ func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, er
if err != nil {
return ethereum, fmt.Errorf("Block Test load error: %v", err)
}
- newDB := cm.State()
+ newDB, err := cm.State()
+ if err != nil {
+ return ethereum, fmt.Errorf("Block Test get state error: %v", err)
+ }
if err := test.ValidatePostState(newDB); err != nil {
return ethereum, fmt.Errorf("post state validation failed: %v", err)
}
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index c5bc4b66a..80f3777d6 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -179,7 +179,11 @@ func dump(ctx *cli.Context) {
fmt.Println("{}")
utils.Fatalf("block not found")
} else {
- state := state.New(block.Root(), chainDb)
+ state, err := state.New(block.Root(), chainDb)
+ if err != nil {
+ utils.Fatalf("could not create new state: %v", err)
+ return
+ }
fmt.Printf("%s\n", state.Dump())
}
}