diff options
author | Sonic <sonic@dexon.org> | 2019-01-03 17:18:50 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:55 +0800 |
commit | 84f8776bf74bbf525ab5e716d16b4e678c56a7a1 (patch) | |
tree | 684fb3e3cea0a24f74f696ae401daee343e09f22 /core/blockchain.go | |
parent | bfa5a27d0034ab25785d80ad20a9e0559ee78dcd (diff) | |
download | dexon-84f8776bf74bbf525ab5e716d16b4e678c56a7a1.tar dexon-84f8776bf74bbf525ab5e716d16b4e678c56a7a1.tar.gz dexon-84f8776bf74bbf525ab5e716d16b4e678c56a7a1.tar.bz2 dexon-84f8776bf74bbf525ab5e716d16b4e678c56a7a1.tar.lz dexon-84f8776bf74bbf525ab5e716d16b4e678c56a7a1.tar.xz dexon-84f8776bf74bbf525ab5e716d16b4e678c56a7a1.tar.zst dexon-84f8776bf74bbf525ab5e716d16b4e678c56a7a1.zip |
core, indexer, dex: fix DexconApp block deliver after synced (#122)
When starts a bp node to sync with the network, bc.chainLastHeight map
may not be initialized yet.
Just return error if we can not get chain last height when preparing
payload and verify block.
Diffstat (limited to 'core/blockchain.go')
-rw-r--r-- | core/blockchain.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index 72837e324..d6e116008 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -395,12 +395,13 @@ func (bc *BlockChain) GetCostInConfirmedBlocks(chainID uint32, address common.Ad return cost, exist } -func (bc *BlockChain) GetChainLastConfirmedHeight(chainID uint32) uint64 { - val, ok := bc.chainLastHeight.Load(chainID) - if !ok { - panic(fmt.Errorf("failed to get chain last height, chainID = %d", chainID)) +func (bc *BlockChain) GetChainLastConfirmedHeight(chainID uint32) (uint64, bool) { + val := uint64(0) + v, ok := bc.chainLastHeight.Load(chainID) + if ok { + val = v.(uint64) } - return val.(uint64) + return val, ok } func (bc *BlockChain) GetAddressInfo(chainID uint32, address common.Address) ( |