From bebcd229959b250a4127bdd678b49048ee0208ea Mon Sep 17 00:00:00 2001 From: Sonic Date: Fri, 21 Dec 2018 14:53:37 +0800 Subject: 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. --- core/blockchain.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'core/blockchain.go') diff --git a/core/blockchain.go b/core/blockchain.go index 1b3b22e5e..0e87360c3 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1796,8 +1796,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) @@ -1810,8 +1808,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 { -- cgit v1.2.3