ErrBadBlock = errors.New("invalid block")
// ErrBadStateRoot is returned when the computed assets merkle root
// disagrees with the one declared in a block header.
- ErrBadStateRoot = errors.New("invalid state merkle root")
+ ErrBadStateRoot = errors.New("invalid state merkle root")
+ errBelowIrreversibleBlock = errors.New("the height of block below the height of irreversible block")
)
// BlockExist check is a block in chain or orphan
// ProcessBlock is the entry for handle block insert
func (c *Chain) processBlock(block *types.Block) (bool, error) {
+ blockHash := block.Hash()
if block.Height <= c.bestIrreversibleNode.Height {
- return false, errors.New("the height of block below the height of irreversible block")
+ log.WithFields(log.Fields{"module": logModule, "hash": blockHash.String(), "height": block.Height}).Info(errBelowIrreversibleBlock.Error())
+ return false, errBelowIrreversibleBlock
}
- blockHash := block.Hash()
if c.BlockExist(&blockHash) {
log.WithFields(log.Fields{"module": logModule, "hash": blockHash.String(), "height": block.Height}).Info("block has been processed")
return c.orphanManage.BlockExist(&blockHash), nil
mainChainNode := c.blockIndex.GetNode(&voteResult.BlockHash)
var attachNodes []*state.BlockNode
var detachNodes []*state.BlockNode
- for forkChainNode := node; mainChainNode != forkChainNode; node = node.Parent {
+ for forkChainNode := node; mainChainNode != forkChainNode; forkChainNode = forkChainNode.Parent {
if forkChainNode.Height == mainChainNode.Height {
detachNodes = append(detachNodes, mainChainNode)
mainChainNode = mainChainNode.Parent