change state syncing if the node is doing consensus

pull/125/head
Minh Doan 6 years ago
parent 004b906d08
commit 89bf6b4668
  1. 16
      node/node_handler.go

@ -403,18 +403,26 @@ func (node *Node) BroadcastNewBlock(newBlock *blockchain.Block) {
// VerifyNewBlock is called by consensus participants to verify the block they are running consensus on
func (node *Node) VerifyNewBlock(newBlock *blockchain.Block) bool {
// TODO: just a reminder for syncing. we need to check if the new block is fit with the current blockchain.
// The current blockchain can be in the progress of being synced.
var verified bool
if newBlock.AccountBlock != nil {
accountBlock := new(types.Block)
err := rlp.DecodeBytes(newBlock.AccountBlock, accountBlock)
if err != nil {
node.log.Error("Failed decoding the block with RLP")
}
return node.VerifyNewBlockAccount(accountBlock)
verified = node.VerifyNewBlockAccount(accountBlock)
} else if newBlock.IsStateBlock() {
verified = node.UtxoPool.VerifyStateBlock(newBlock)
} else {
verified = node.UtxoPool.VerifyTransactions(newBlock.Transactions)
}
if newBlock.IsStateBlock() {
return node.UtxoPool.VerifyStateBlock(newBlock)
if verified {
// Change the syncing state.
node.State = NodeDoingConsensus
}
return node.UtxoPool.VerifyTransactions(newBlock.Transactions)
return verified
}
// VerifyNewBlockAccount is called by consensus participants to verify the block (account model) they are running consensus on

Loading…
Cancel
Save