aboutsummaryrefslogtreecommitdiffstats
path: root/core/genesis.go
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 /core/genesis.go
parentf466243417f60531998e8b500f2bb043af5b3d2a (diff)
downloadgo-tangerine-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar
go-tangerine-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.gz
go-tangerine-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.bz2
go-tangerine-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.lz
go-tangerine-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.xz
go-tangerine-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.zst
go-tangerine-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.zip
core/state, core, miner: handle missing root error from state.New
Diffstat (limited to 'core/genesis.go')
-rw-r--r--core/genesis.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/genesis.go b/core/genesis.go
index 4c5c17f60..16c1598c2 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -60,7 +60,8 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
return nil, err
}
- statedb := state.New(common.Hash{}, chainDb)
+ // creating with empty hash always works
+ statedb, _ := state.New(common.Hash{}, chainDb)
for addr, account := range genesis.Alloc {
address := common.HexToAddress(addr)
statedb.AddBalance(address, common.String2Big(account.Balance))
@@ -115,9 +116,9 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
}
// GenesisBlockForTesting creates a block in which addr has the given wei balance.
-// The state trie of the block is written to db.
+// The state trie of the block is written to db. the passed db needs to contain a state root
func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block {
- statedb := state.New(common.Hash{}, db)
+ statedb, _ := state.New(common.Hash{}, db)
obj := statedb.GetOrNewStateObject(addr)
obj.SetBalance(balance)
root, err := statedb.Commit()