@@ -42,20 +42,15 @@ var (
4242)
4343
4444var (
45- ErrInvalidChain = errors .New ("invalid header chain" )
46- ErrParentUnknown = errors .New ("parent not known locally" )
47- ErrFutureBlock = errors .New ("block in the future" )
48- ErrLargeBlockTimestamp = errors .New ("timestamp too big" )
49- ErrZeroBlockTime = errors .New ("timestamp equals parent's" )
50- ErrInvalidNumber = errors .New ("invalid block number" )
51- ErrTooManyUncles = errors .New ("too many uncles" )
52- ErrDuplicateUncle = errors .New ("duplicate uncle" )
53- ErrUncleIsAncestor = errors .New ("uncle is ancestor" )
54- ErrDanglingUncle = errors .New ("uncle's parent is not ancestor" )
55- ErrNonceOutOfRange = errors .New ("nonce out of range" )
56- ErrInvalidDifficulty = errors .New ("non-positive difficulty" )
57- ErrInvalidMixDigest = errors .New ("invalid mix digest" )
58- ErrInvalidPoW = errors .New ("invalid proof-of-work" )
45+ ErrInvalidChain = errors .New ("invalid header chain" )
46+ ErrTooManyUncles = errors .New ("too many uncles" )
47+ ErrDuplicateUncle = errors .New ("duplicate uncle" )
48+ ErrUncleIsAncestor = errors .New ("uncle is ancestor" )
49+ ErrDanglingUncle = errors .New ("uncle's parent is not ancestor" )
50+ ErrNonceOutOfRange = errors .New ("nonce out of range" )
51+ ErrInvalidDifficulty = errors .New ("non-positive difficulty" )
52+ ErrInvalidMixDigest = errors .New ("invalid mix digest" )
53+ ErrInvalidPoW = errors .New ("invalid proof-of-work" )
5954)
6055
6156// VerifyHeader checks whether a header conforms to the consensus rules of the
@@ -72,7 +67,7 @@ func (ethash *Ethash) VerifyHeader(chain consensus.ChainReader, header *types.He
7267 }
7368 parent := chain .GetHeader (header .ParentHash , number - 1 )
7469 if parent == nil {
75- return ErrParentUnknown
70+ return consensus . ErrUnknownAncestor
7671 }
7772 // Sanity checks passed, do a proper verification
7873 return ethash .verifyHeader (chain , header , parent , false , seal )
@@ -125,7 +120,7 @@ func (ethash *Ethash) VerifyHeaders(chain consensus.ChainReader, headers []*type
125120 case chain .GetHeader (headers [index ].Hash (), headers [index ].Number .Uint64 ()- 1 ) != nil :
126121 outputs <- result {index : index , err : nil }
127122 case parent == nil :
128- failure = ErrParentUnknown
123+ failure = consensus . ErrUnknownAncestor
129124 outputs <- result {index : index , err : failure }
130125 default :
131126 failure = ethash .verifyHeader (chain , headers [index ], parent , false , seals [index ])
@@ -254,15 +249,15 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
254249 // Verify the header's timestamp
255250 if uncle {
256251 if header .Time .Cmp (math .MaxBig256 ) > 0 {
257- return ErrLargeBlockTimestamp
252+ return consensus . ErrLargeBlockTime
258253 }
259254 } else {
260255 if header .Time .Cmp (big .NewInt (time .Now ().Unix ())) > 0 {
261- return ErrFutureBlock
256+ return consensus . ErrFutureBlock
262257 }
263258 }
264259 if header .Time .Cmp (parent .Time ) <= 0 {
265- return ErrZeroBlockTime
260+ return consensus . ErrZeroBlockTime
266261 }
267262 // Verify the block's difficulty based in it's timestamp and parent's difficulty
268263 expected := CalcDifficulty (chain .Config (), header .Time .Uint64 (), parent .Time .Uint64 (), parent .Number , parent .Difficulty )
@@ -282,7 +277,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
282277 }
283278 // Verify that the block number is parent's +1
284279 if diff := new (big.Int ).Sub (header .Number , parent .Number ); diff .Cmp (big .NewInt (1 )) != 0 {
285- return ErrInvalidNumber
280+ return consensus . ErrInvalidNumber
286281 }
287282 // Verify the engine specific seal securing the block
288283 if seal {
@@ -449,7 +444,7 @@ func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Head
449444func (ethash * Ethash ) Prepare (chain consensus.ChainReader , header * types.Header ) error {
450445 parent := chain .GetHeader (header .ParentHash , header .Number .Uint64 ()- 1 )
451446 if parent == nil {
452- return ErrParentUnknown
447+ return consensus . ErrUnknownAncestor
453448 }
454449 header .Difficulty = CalcDifficulty (chain .Config (), header .Time .Uint64 (),
455450 parent .Time .Uint64 (), parent .Number , parent .Difficulty )
0 commit comments