mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
consensus/ethash, core/types: further review fixes
This commit is contained in:
parent
fc6cf3f8cf
commit
c65e3309fd
2 changed files with 2 additions and 28 deletions
|
|
@ -38,6 +38,7 @@ import (
|
||||||
// Ethash proof-of-work protocol constants.
|
// Ethash proof-of-work protocol constants.
|
||||||
var (
|
var (
|
||||||
blockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
|
blockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
|
||||||
|
maxUncles = 2 // Maximum number of uncles allowed in a single block
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -197,7 +198,7 @@ func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Blo
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Verify that there are at most 2 uncles included in this block
|
// Verify that there are at most 2 uncles included in this block
|
||||||
if len(block.Uncles()) > 2 {
|
if len(block.Uncles()) > maxUncles {
|
||||||
return ErrTooManyUncles
|
return ErrTooManyUncles
|
||||||
}
|
}
|
||||||
// Gather the set of past uncles and ancestors
|
// Gather the set of past uncles and ancestors
|
||||||
|
|
|
||||||
|
|
@ -120,33 +120,6 @@ func (h *Header) HashNoNonce() common.Hash {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// HashNoPoASig returns the hash which is used as input for the proof-of-authority
|
|
||||||
// signing. It is the hash of the entire header apart from the 65 byte signature
|
|
||||||
// contained at the end of the extra data.
|
|
||||||
//
|
|
||||||
// Note, the method requires the extra data to be at least 65 bytes, otherwise it
|
|
||||||
// panics. This is done to avoid accidentally using both forms (signature present
|
|
||||||
// or not), which could be abused to produce different hashes for the same header.
|
|
||||||
func (h *Header) HashNoPoASig() common.Hash {
|
|
||||||
return rlpHash([]interface{}{
|
|
||||||
h.ParentHash,
|
|
||||||
h.UncleHash,
|
|
||||||
h.Coinbase,
|
|
||||||
h.Root,
|
|
||||||
h.TxHash,
|
|
||||||
h.ReceiptHash,
|
|
||||||
h.Bloom,
|
|
||||||
h.Difficulty,
|
|
||||||
h.Number,
|
|
||||||
h.GasLimit,
|
|
||||||
h.GasUsed,
|
|
||||||
h.Time,
|
|
||||||
h.Extra[:len(h.Extra)-65], // Yes, this will panic
|
|
||||||
h.MixDigest,
|
|
||||||
h.Nonce,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func rlpHash(x interface{}) (h common.Hash) {
|
func rlpHash(x interface{}) (h common.Hash) {
|
||||||
hw := sha3.NewKeccak256()
|
hw := sha3.NewKeccak256()
|
||||||
rlp.Encode(hw, x)
|
rlp.Encode(hw, x)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue