aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2018-12-21 14:53:37 +0800
committerGitHub <noreply@github.com>2018-12-21 14:53:37 +0800
commitb680d7be8c4d11fbb1b7ece43bcee93217d0278e (patch)
treed566e0b07b5a23f8f1dc53cd0b3926b2b060bfb8 /core/blockchain.go
parente27667c7563e71adc766fb1155c340cca91f33e0 (diff)
downloaddexon-b680d7be8c4d11fbb1b7ece43bcee93217d0278e.tar
dexon-b680d7be8c4d11fbb1b7ece43bcee93217d0278e.tar.gz
dexon-b680d7be8c4d11fbb1b7ece43bcee93217d0278e.tar.bz2
dexon-b680d7be8c4d11fbb1b7ece43bcee93217d0278e.tar.lz
dexon-b680d7be8c4d11fbb1b7ece43bcee93217d0278e.tar.xz
dexon-b680d7be8c4d11fbb1b7ece43bcee93217d0278e.tar.zst
dexon-b680d7be8c4d11fbb1b7ece43bcee93217d0278e.zip
core, dex, internal: block proposer syncing (first iteration) (#96)
* dex, internal: block proposer syncing (first iteration) * core: find block from db if not in memory This fix handles stopping proposing and then restarting * core: no need to reorg when reset Dexon will not fork. This commit also fix when a block confirm but its parent is not in db yet, during restarting proposing. * dex: always accept NewBlockMsg, NewBlockHashesMsg We need to accept NewBlockMsg, NewBlockHashesMsg to sync current block with other peers in block proposer mode when syncing lattice data. It's a waste when the node is synced and start proposing. Todo: control msg processing on/off more granular, accept NewBlockMsg, NewBlockHashesMsg when syncing, but stop when synced.
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index afb9dfc2e..b00f24d4f 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -1790,8 +1790,6 @@ func (bc *BlockChain) processPendingBlock(
return nil, nil, nil, fmt.Errorf("validate witness data error: %v", err)
}
- currentBlock := bc.CurrentBlock()
-
var (
receipts types.Receipts
usedGas = new(uint64)
@@ -1804,8 +1802,8 @@ func (bc *BlockChain) processPendingBlock(
var err error
parent, exist := bc.pendingBlocks[block.NumberU64()-1]
if !exist {
- parentBlock = currentBlock
- if parentBlock.NumberU64() != block.NumberU64()-1 {
+ parentBlock = bc.GetBlockByNumber(block.NumberU64() - 1)
+ if parentBlock == nil {
return nil, nil, nil, fmt.Errorf("parent block %d not exist", block.NumberU64()-1)
}
} else {