From a7b9e484d05ceb0afce4ba5dbc62b8f262c2e354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 12 Apr 2017 16:38:31 +0300 Subject: consensus, core, ethstats: use engine specific block beneficiary (#14318) * consensus, core, ethstats: use engine specific block beneficiary * core, eth, les, miner: use explicit beneficiary during mining --- consensus/clique/clique.go | 6 ++++++ consensus/consensus.go | 5 +++++ consensus/ethash/consensus.go | 6 ++++++ 3 files changed, 17 insertions(+) (limited to 'consensus') diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 3c36545c4..8619bd1d8 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -220,6 +220,12 @@ func New(config *params.CliqueConfig, db ethdb.Database) *Clique { } } +// Author implements consensus.Engine, returning the Ethereum address recovered +// from the signature in the header's extra-data section. +func (c *Clique) Author(header *types.Header) (common.Address, error) { + return ecrecover(header) +} + // VerifyHeader checks whether a header conforms to the consensus rules. func (c *Clique) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error { return c.verifyHeader(chain, header, nil) diff --git a/consensus/consensus.go b/consensus/consensus.go index c199e627f..8cbd32c88 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -49,6 +49,11 @@ type ChainReader interface { // Engine is an algorithm agnostic consensus engine. type Engine interface { + // Author retrieves the Ethereum address of the account that minted the given + // block, which may be different from the header's coinbase if a consensus + // engine is based on signatures. + Author(header *types.Header) (common.Address, error) + // VerifyHeader checks whether a header conforms to the consensus rules of a // given engine. Verifying the seal may be done optionally here, or explicitly // via the VerifySeal method. diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index f4f8f4b17..4b6e779d5 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -59,6 +59,12 @@ var ( errInvalidPoW = errors.New("invalid proof-of-work") ) +// Author implements consensus.Engine, returning the header's coinbase as the +// proof-of-work verified author of the block. +func (ethash *Ethash) Author(header *types.Header) (common.Address, error) { + return header.Coinbase, nil +} + // VerifyHeader checks whether a header conforms to the consensus rules of the // stock Ethereum ethash engine. func (ethash *Ethash) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error { -- cgit v1.2.3