aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-01-03 17:18:50 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commitf9e8fba11b1e06794f89b7fb5175480a3eded5f2 (patch)
treeeb971da377ee5f21f3221d86d99be4c6a7e1208b /core
parent9f0fe7967af4b8d300ece5e9a406d75287dd964c (diff)
downloaddexon-f9e8fba11b1e06794f89b7fb5175480a3eded5f2.tar
dexon-f9e8fba11b1e06794f89b7fb5175480a3eded5f2.tar.gz
dexon-f9e8fba11b1e06794f89b7fb5175480a3eded5f2.tar.bz2
dexon-f9e8fba11b1e06794f89b7fb5175480a3eded5f2.tar.lz
dexon-f9e8fba11b1e06794f89b7fb5175480a3eded5f2.tar.xz
dexon-f9e8fba11b1e06794f89b7fb5175480a3eded5f2.tar.zst
dexon-f9e8fba11b1e06794f89b7fb5175480a3eded5f2.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')
-rw-r--r--core/blockchain.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index c5e2f6bf4..b4a2882dd 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) (