@@ -138,7 +138,7 @@ func (ga *GenesisAlloc) deriveHash() (common.Hash, error) {
138
138
// flush is very similar with deriveHash, but the main difference is
139
139
// all the generated states will be persisted into the given database.
140
140
// Also, the genesis state specification will be flushed as well.
141
- func (ga * GenesisAlloc ) flush (db ethdb.Database , triedb * trie.Database ) error {
141
+ func (ga * GenesisAlloc ) flush (db ethdb.Database , triedb * trie.Database , blockhash common. Hash ) error {
142
142
statedb , err := state .New (common.Hash {}, state .NewDatabaseWithNodeDB (db , triedb ), nil )
143
143
if err != nil {
144
144
return err
@@ -166,15 +166,15 @@ func (ga *GenesisAlloc) flush(db ethdb.Database, triedb *trie.Database) error {
166
166
if err != nil {
167
167
return err
168
168
}
169
- rawdb .WriteGenesisStateSpec (db , root , blob )
169
+ rawdb .WriteGenesisStateSpec (db , blockhash , blob )
170
170
return nil
171
171
}
172
172
173
173
// CommitGenesisState loads the stored genesis state with the given block
174
174
// hash and commits it into the provided trie database.
175
- func CommitGenesisState (db ethdb.Database , triedb * trie.Database , hash common.Hash ) error {
175
+ func CommitGenesisState (db ethdb.Database , triedb * trie.Database , blockhash common.Hash ) error {
176
176
var alloc GenesisAlloc
177
- blob := rawdb .ReadGenesisStateSpec (db , hash )
177
+ blob := rawdb .ReadGenesisStateSpec (db , blockhash )
178
178
if len (blob ) != 0 {
179
179
if err := alloc .UnmarshalJSON (blob ); err != nil {
180
180
return err
@@ -186,7 +186,7 @@ func CommitGenesisState(db ethdb.Database, triedb *trie.Database, hash common.Ha
186
186
// - supported networks(mainnet, testnets), recover with defined allocations
187
187
// - private network, can't recover
188
188
var genesis * Genesis
189
- switch hash {
189
+ switch blockhash {
190
190
case params .MainnetGenesisHash :
191
191
genesis = DefaultGenesisBlock ()
192
192
case params .RinkebyGenesisHash :
@@ -202,7 +202,7 @@ func CommitGenesisState(db ethdb.Database, triedb *trie.Database, hash common.Ha
202
202
return errors .New ("not found" )
203
203
}
204
204
}
205
- return alloc .flush (db , triedb )
205
+ return alloc .flush (db , triedb , blockhash )
206
206
}
207
207
208
208
// GenesisAccount is an account in the state of the genesis block.
@@ -493,7 +493,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database) (*types.Block
493
493
// All the checks has passed, flush the states derived from the genesis
494
494
// specification as well as the specification itself into the provided
495
495
// database.
496
- if err := g .Alloc .flush (db , triedb ); err != nil {
496
+ if err := g .Alloc .flush (db , triedb , block . Hash () ); err != nil {
497
497
return nil , err
498
498
}
499
499
rawdb .WriteTd (db , block .Hash (), block .NumberU64 (), block .Difficulty ())
0 commit comments