mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
refactor big int compare and fix 1 bug on headers
This commit is contained in:
parent
221326aafc
commit
491dc911f3
2 changed files with 7 additions and 5 deletions
|
|
@ -180,10 +180,10 @@ func (x *XDPoS) VerifyHeaders(chain consensus.ChainReader, headers []*types.Head
|
||||||
}
|
}
|
||||||
|
|
||||||
if v1headers != nil {
|
if v1headers != nil {
|
||||||
x.EngineV1.VerifyHeaders(chain, headers, fullVerifies, abort, results)
|
x.EngineV1.VerifyHeaders(chain, v1headers, fullVerifies, abort, results)
|
||||||
}
|
}
|
||||||
if v2headers != nil {
|
if v2headers != nil {
|
||||||
x.EngineV2.VerifyHeaders(chain, headers, fullVerifies, abort, results)
|
x.EngineV2.VerifyHeaders(chain, v2headers, fullVerifies, abort, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
return abort, results
|
return abort, results
|
||||||
|
|
|
||||||
|
|
@ -551,13 +551,13 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
|
||||||
if header.Number == nil {
|
if header.Number == nil {
|
||||||
return utils.ErrUnknownBlock
|
return utils.ErrUnknownBlock
|
||||||
}
|
}
|
||||||
number := header.Number.Uint64()
|
|
||||||
if fullVerify {
|
if fullVerify {
|
||||||
if len(header.Validator) == 0 {
|
if len(header.Validator) == 0 {
|
||||||
return consensus.ErrNoValidatorSignature
|
return consensus.ErrNoValidatorSignature
|
||||||
}
|
}
|
||||||
// Don't waste time checking blocks from the future
|
// Don't waste time checking blocks from the future
|
||||||
if header.Time.Cmp(big.NewInt(time.Now().Unix())) > 0 {
|
if header.Time.Int64() > time.Now().Unix() {
|
||||||
return consensus.ErrFutureBlock
|
return consensus.ErrFutureBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -593,7 +593,7 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
|
||||||
// Verify v2 block that is on the epoch switch
|
// Verify v2 block that is on the epoch switch
|
||||||
if header.Validators != nil {
|
if header.Validators != nil {
|
||||||
// Skip if it's the first v2 block as it wil inherit from last v1 epoch block
|
// Skip if it's the first v2 block as it wil inherit from last v1 epoch block
|
||||||
if header.Number.Cmp(new(big.Int).Add(x.config.V2.SwitchBlock, big.NewInt(1))) == 1 && header.Coinbase != (common.Address{}) {
|
if header.Number.Uint64() > x.config.V2.SwitchBlock.Uint64()+1 && header.Coinbase != (common.Address{}) {
|
||||||
return utils.ErrInvalidCheckpointBeneficiary
|
return utils.ErrInvalidCheckpointBeneficiary
|
||||||
}
|
}
|
||||||
if !bytes.Equal(header.Nonce[:], utils.NonceDropVote) {
|
if !bytes.Equal(header.Nonce[:], utils.NonceDropVote) {
|
||||||
|
|
@ -614,6 +614,8 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
|
||||||
|
|
||||||
// Ensure that the block's timestamp isn't too close to it's parent
|
// Ensure that the block's timestamp isn't too close to it's parent
|
||||||
var parent *types.Header
|
var parent *types.Header
|
||||||
|
number := header.Number.Uint64()
|
||||||
|
|
||||||
if len(parents) > 0 {
|
if len(parents) > 0 {
|
||||||
parent = parents[len(parents)-1]
|
parent = parents[len(parents)-1]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue