Skip to content

Commit

Permalink
validate body add received allready confirm block access
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbin authored and ttblack committed Jul 20, 2022
1 parent 492e9ee commit ce100b2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/block_validator.go
Expand Up @@ -18,7 +18,6 @@ package core

import (
"fmt"

"github.com/elastos/Elastos.ELA.SideChain.ESC/consensus"
"github.com/elastos/Elastos.ELA.SideChain.ESC/core/state"
"github.com/elastos/Elastos.ELA.SideChain.ESC/core/types"
Expand Down Expand Up @@ -53,6 +52,13 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
if v.engine.IsInBlockPool(block.Hash()) {
return nil
}
oldBlock := v.bc.GetBlockByNumber(block.NumberU64())
if oldBlock != nil && v.bc.chainConfig.IsPBFTFork(block.Number()) {
current := v.bc.CurrentHeader()
if block.Number().Cmp(current.Number) < 0 {
return consensus.ErrInvalidNumber
}
}
// Check whether the block's known, and if not, that it's linkable
if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) {
return ErrKnownBlock
Expand Down

0 comments on commit ce100b2

Please sign in to comment.