diff options
author | Sonic <sonic@dexon.org> | 2018-11-14 15:41:09 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | db3df912de04a426b0d03eb7dac20f1c4a18d594 (patch) | |
tree | 4ec6c910ff986487349c97a5c39df25b77a218ed | |
parent | 5503a972fc62483819b8c3b838c38ff4713a59ae (diff) | |
download | dexon-db3df912de04a426b0d03eb7dac20f1c4a18d594.tar.gz dexon-db3df912de04a426b0d03eb7dac20f1c4a18d594.tar.zst dexon-db3df912de04a426b0d03eb7dac20f1c4a18d594.zip |
core: use storeRoundHeight to avoid type mismatch (#21)
No need to store round 0, it's already pushed in genesis block
-rw-r--r-- | core/blockchain.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 0486388ca..8c8c8656b 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -232,9 +232,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par } } - // Set genesis round height mapping. - bc.roundHeightMap.Store(0, 0) - // Take ownership of this particular state go bc.update() return bc, nil @@ -308,9 +305,6 @@ func NewBlockChainWithDexonValidator(db ethdb.Database, cacheConfig *CacheConfig } } - // Set genesis round height mapping. - bc.roundHeightMap.Store(0, 0) - // Take ownership of this particular state go bc.update() return bc, nil @@ -1745,9 +1739,8 @@ func (bc *BlockChain) processPendingBlock(block *types.Block, witness *coreTypes cache, _ := bc.stateCache.TrieDB().Size() stats.report([]*types.Block{pendingIns.block}, 0, cache) - _, ok := bc.roundHeightMap.Load(pendingIns.block.Round()) - if !ok { - bc.roundHeightMap.Store(pendingIns.block.Round(), pendingHeight) + if _, ok := bc.GetRoundHeight(pendingIns.block.Round()); !ok { + bc.storeRoundHeight(pendingIns.block.Round(), pendingHeight) } } // Append a single chain head event if we've progressed the chain @@ -2149,3 +2142,7 @@ func (bc *BlockChain) GetRoundHeight(round uint64) (uint64, bool) { } return h.(uint64), true } + +func (bc *BlockChain) storeRoundHeight(round uint64, height uint64) { + bc.roundHeightMap.Store(round, height) +} |