aboutsummaryrefslogtreecommitdiffstats
path: root/dex/app.go
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 /dex/app.go
parent7c31a0ecb0cf29a0e4b8a7ef3fb3930ac2cf072d (diff)
downloadgo-tangerine-b92aa8f1590c3ecb1e2fe8ba12a5092ca190786c.tar.gz
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 'dex/app.go')
-rw-r--r--dex/app.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/dex/app.go b/dex/app.go
index d04b2afd6..c52a6c79b 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -177,11 +177,11 @@ func (d *DexconApp) preparePayload(ctx context.Context, position coreTypes.Posit
if position.Height != 0 {
// Check if chain block height is strictly increamental.
- chainLastHeight := d.blockchain.GetChainLastConfirmedHeight(position.ChainID)
- if chainLastHeight != position.Height-1 {
- log.Error("Check confirmed block height fail",
- "chain", position.ChainID, "height", position.Height-1, "cache height", chainLastHeight)
- return nil, fmt.Errorf("check confirmed block height fail")
+ chainLastHeight, ok := d.blockchain.GetChainLastConfirmedHeight(position.ChainID)
+ if !ok || chainLastHeight != position.Height-1 {
+ log.Debug("Previous confirmed block not exists", "current pos", position.String(),
+ "prev height", chainLastHeight, "ok", ok)
+ return nil, fmt.Errorf("previous block not exists")
}
}
@@ -337,10 +337,10 @@ func (d *DexconApp) VerifyBlock(block *coreTypes.Block) coreTypes.BlockVerifySta
if block.Position.Height != 0 {
// Check if target block is the next height to be verified, we can only
// verify the next block in a given chain.
- chainLastHeight := d.blockchain.GetChainLastConfirmedHeight(block.Position.ChainID)
- if chainLastHeight != block.Position.Height-1 {
- log.Error("Check confirmed block height fail", "chain", block.Position.ChainID,
- "height", block.Position.Height-1, "cache height", chainLastHeight)
+ chainLastHeight, ok := d.blockchain.GetChainLastConfirmedHeight(block.Position.ChainID)
+ if !ok || chainLastHeight != block.Position.Height-1 {
+ log.Debug("Previous confirmed block not exists", "current pos", block.Position.String(),
+ "prev height", chainLastHeight, "ok", ok)
return coreTypes.VerifyRetryLater
}
}