consensus/ethash, core/types: further review fixes

This commit is contained in:
Péter Szilágyi 2017-04-04 12:24:50 +03:00
parent fc6cf3f8cf
commit c65e3309fd
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D
2 changed files with 2 additions and 28 deletions

View file

@ -38,6 +38,7 @@ import (
// Ethash proof-of-work protocol constants.
var (
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 (
@ -197,7 +198,7 @@ func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Blo
return nil
}
// Verify that there are at most 2 uncles included in this block
if len(block.Uncles()) > 2 {
if len(block.Uncles()) > maxUncles {
return ErrTooManyUncles
}
// Gather the set of past uncles and ancestors

View file

@ -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) {
hw := sha3.NewKeccak256()
rlp.Encode(hw, x)