Enforce that Extra field on block matches a preset value

This commit is contained in:
Luke Williams 2016-05-03 16:30:48 +10:00
parent 26d69d69c5
commit 1a6fbacb64

View file

@ -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)
}