forked from TrueCloudLab/neoneo-go
core: move stateroot check into header check
As it's a part of the header.
This commit is contained in:
parent
1fdd406234
commit
56fd375c6d
1 changed files with 6 additions and 6 deletions
|
@ -501,12 +501,6 @@ func (bc *Blockchain) AddBlock(block *block.Block) error {
|
|||
return fmt.Errorf("%w: %v != %v",
|
||||
ErrHdrStateRootSetting, bc.config.StateRootInHeader, block.StateRootEnabled)
|
||||
}
|
||||
if bc.config.StateRootInHeader {
|
||||
if sr := bc.stateRoot.CurrentLocalStateRoot(); block.PrevStateRoot != sr {
|
||||
return fmt.Errorf("%w: %s != %s",
|
||||
ErrHdrInvalidStateRoot, block.PrevStateRoot.StringLE(), sr.StringLE())
|
||||
}
|
||||
}
|
||||
|
||||
if block.Index == bc.HeaderHeight()+1 {
|
||||
err := bc.addHeaders(bc.config.VerifyBlocks, &block.Header)
|
||||
|
@ -1391,6 +1385,12 @@ var (
|
|||
)
|
||||
|
||||
func (bc *Blockchain) verifyHeader(currHeader, prevHeader *block.Header) error {
|
||||
if bc.config.StateRootInHeader {
|
||||
if sr := bc.stateRoot.CurrentLocalStateRoot(); currHeader.PrevStateRoot != sr {
|
||||
return fmt.Errorf("%w: %s != %s",
|
||||
ErrHdrInvalidStateRoot, currHeader.PrevStateRoot.StringLE(), sr.StringLE())
|
||||
}
|
||||
}
|
||||
if prevHeader.Hash() != currHeader.PrevHash {
|
||||
return ErrHdrHashMismatch
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue