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-04-09 13:50:00 +0800
commit37ea59cb3afb8f33935aa517a7a59bf9166100c8 (patch)
tree513c4d5bf337b1d68ef393cb23fb109f430aa1b4 /core
parente935c7b0634aaa6254bf7e0a2ae4a9b382015702 (diff)
downloaddexon-37ea59cb3afb8f33935aa517a7a59bf9166100c8.tar
dexon-37ea59cb3afb8f33935aa517a7a59bf9166100c8.tar.gz
dexon-37ea59cb3afb8f33935aa517a7a59bf9166100c8.tar.bz2
dexon-37ea59cb3afb8f33935aa517a7a59bf9166100c8.tar.lz
dexon-37ea59cb3afb8f33935aa517a7a59bf9166100c8.tar.xz
dexon-37ea59cb3afb8f33935aa517a7a59bf9166100c8.tar.zst
dexon-37ea59cb3afb8f33935aa517a7a59bf9166100c8.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 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) (