4 "github.com/vapor/chain"
5 "github.com/vapor/protocol/bc"
6 "github.com/vapor/protocol/bc/types"
9 // Engine is an algorithm agnostic consensus engine.
10 type Engine interface {
11 // Author retrieves the Ethereum address of the account that minted the given
12 // block, which may be different from the header's coinbase if a consensus
13 // engine is based on signatures.
14 Author(header *types.BlockHeader, c chain.Chain) (string, error)
16 // VerifyHeader checks whether a header conforms to the consensus rules of a
17 // given engine. Verifying the seal may be done optionally here, or explicitly
18 // via the VerifySeal method.
19 VerifyHeader(c chain.Chain, header *types.BlockHeader, seal bool) error
21 // VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers
22 // concurrently. The method returns a quit channel to abort the operations and
23 // a results channel to retrieve the async verifications (the order is that of
25 VerifyHeaders(c chain.Chain, headers []*types.BlockHeader, seals []bool) (chan<- struct{}, <-chan error)
27 // VerifySeal checks whether the crypto seal on a header is valid according to
28 // the consensus rules of the given engine.
29 VerifySeal(c chain.Chain, header *types.BlockHeader) error
31 // Prepare initializes the consensus fields of a block header according to the
32 // rules of a particular engine. The changes are executed inline.
33 Prepare(c chain.Chain, header *types.BlockHeader) error
35 // Finalize runs any post-transaction state modifications (e.g. block rewards)
36 // and assembles the final block.
37 // Note: The block header and state database might be updated to reflect any
38 // consensus rules that happen at finalization (e.g. block rewards).
39 Finalize(c chain.Chain, header *types.BlockHeader, txs []*bc.Tx) error
41 // Seal generates a new block for the given input block with the local miner's
43 Seal(c chain.Chain, block *types.Block) (*types.Block, error)