aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-01-03 17:18:50 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:21 +0800
commitb92aa8f1590c3ecb1e2fe8ba12a5092ca190786c (patch)
tree7973c621498f492d32de8a5d0c28f8a290a89419 /core
parent7c31a0ecb0cf29a0e4b8a7ef3fb3930ac2cf072d (diff)
downloadgo-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.tar
go-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.tar.gz
go-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.tar.bz2
go-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.tar.lz
go-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.tar.xz
go-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.tar.zst
go-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.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) (