aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2018-11-14 15:41:09 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:18 +0800
commit6e314a141774a54710e797720319ab92ceeff93b (patch)
treeb81de2cdfe0bcbc2d73db059c505f33a0ad23c49 /core
parent4e0dcae8713065ad72fa8b01099f18722ec5c1eb (diff)
downloadgo-tangerine-6e314a141774a54710e797720319ab92ceeff93b.tar.gz
go-tangerine-6e314a141774a54710e797720319ab92ceeff93b.tar.zst
go-tangerine-6e314a141774a54710e797720319ab92ceeff93b.zip
core: use storeRoundHeight to avoid type mismatch (#21)
No need to store round 0, it's already pushed in genesis block
Diffstat (limited to 'core')
-rw-r--r--core/blockchain.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 2bccaf9dc..67bfacb0a 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
@@ -1751,9 +1745,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
@@ -2177,3 +2170,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)
+}