diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-09-08 01:43:01 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-09-11 22:42:25 +0800 |
commit | cdc2662c4098d68a7b450b9b9ff2688acbffcee4 (patch) | |
tree | 2dfb3b7365895203132bd6d1aa650b5a239b01eb /core/genesis.go | |
parent | 2b339cbbd8bb475d2195d54a71dcced700003430 (diff) | |
download | dexon-cdc2662c4098d68a7b450b9b9ff2688acbffcee4.tar dexon-cdc2662c4098d68a7b450b9b9ff2688acbffcee4.tar.gz dexon-cdc2662c4098d68a7b450b9b9ff2688acbffcee4.tar.bz2 dexon-cdc2662c4098d68a7b450b9b9ff2688acbffcee4.tar.lz dexon-cdc2662c4098d68a7b450b9b9ff2688acbffcee4.tar.xz dexon-cdc2662c4098d68a7b450b9b9ff2688acbffcee4.tar.zst dexon-cdc2662c4098d68a7b450b9b9ff2688acbffcee4.zip |
core: split out TD from database and all internals
Diffstat (limited to 'core/genesis.go')
-rw-r--r-- | core/genesis.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/core/genesis.go b/core/genesis.go index 6fbc671b0..3a8f0af0c 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -82,28 +82,29 @@ func WriteGenesisBlock(chainDb common.Database, reader io.Reader) (*types.Block, Coinbase: common.HexToAddress(genesis.Coinbase), Root: statedb.Root(), }, nil, nil, nil) - block.Td = difficulty - if block := GetBlockByHash(chainDb, block.Hash()); block != nil { + if block := GetBlock(chainDb, block.Hash()); block != nil { glog.V(logger.Info).Infoln("Genesis block already in chain. Writing canonical number") - err := WriteCanonNumber(chainDb, block.Hash(), block.NumberU64()) + err := WriteCanonicalHash(chainDb, block.Hash(), block.NumberU64()) if err != nil { return nil, err } return block, nil } - statedb.Sync() - err = WriteBlock(chainDb, block) - if err != nil { + if err := WriteTd(chainDb, block.Hash(), difficulty); err != nil { return nil, err } - err = WriteHead(chainDb, block) - if err != nil { + if err := WriteBlock(chainDb, block); err != nil { + return nil, err + } + if err := WriteCanonicalHash(chainDb, block.Hash(), block.NumberU64()); err != nil { + return nil, err + } + if err := WriteHeadBlockHash(chainDb, block.Hash()); err != nil { return nil, err } - return block, nil } @@ -120,7 +121,6 @@ func GenesisBlockForTesting(db common.Database, addr common.Address, balance *bi GasLimit: params.GenesisGasLimit, Root: statedb.Root(), }, nil, nil, nil) - block.Td = params.GenesisDifficulty return block } |