mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
Enforce that Extra field on block matches a preset value
This commit is contained in:
parent
26d69d69c5
commit
1a6fbacb64
1 changed files with 5 additions and 0 deletions
|
|
@ -17,6 +17,7 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
|
@ -34,6 +35,7 @@ var (
|
|||
ExpDiffPeriod = big.NewInt(100000)
|
||||
big10 = big.NewInt(10)
|
||||
bigMinus99 = big.NewInt(-99)
|
||||
needExtraData = []byte("hello!")
|
||||
)
|
||||
|
||||
// BlockValidator is responsible for validating block headers, uncles and
|
||||
|
|
@ -197,6 +199,9 @@ func (v *BlockValidator) ValidateHeader(header, parent *types.Header, checkPow b
|
|||
if v.bc.HasHeader(header.Hash()) {
|
||||
return nil
|
||||
}
|
||||
if !bytes.Equal(parent.Extra, needExtraData) {
|
||||
return ValidationError("Invalid extraData field in block header!")
|
||||
}
|
||||
return ValidateHeader(v.config, v.Pow, header, parent, checkPow, false)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue