From c65e3309fd31352d547ebebcd48c1d62e8be024d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 4 Apr 2017 12:24:50 +0300 Subject: [PATCH] consensus/ethash, core/types: further review fixes --- consensus/ethash/consensus.go | 3 ++- core/types/block.go | 27 --------------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 4fb32775ca..603be3e531 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -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 diff --git a/core/types/block.go b/core/types/block.go index 20076cfdf4..278594d506 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -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)