OSDN Git Service

modify dpos
[bytom/vapor.git] / consensus / consensus / consensus.go
1 package consensus
2
3 import (
4         "github.com/vapor/chain"
5         "github.com/vapor/protocol/bc"
6         "github.com/vapor/protocol/bc/types"
7 )
8
9 // Engine is an algorithm agnostic consensus engine.
10 type Engine interface {
11
12         // VerifySeal checks whether the crypto seal on a header is valid according to
13         // the consensus rules of the given engine.
14         VerifySeal(c chain.Chain, header *types.BlockHeader) error
15
16         // Prepare initializes the consensus fields of a block header according to the
17         // rules of a particular engine. The changes are executed inline.
18         Prepare(c chain.Chain, header *types.BlockHeader) error
19
20         // Finalize runs any post-transaction state modifications (e.g. block rewards)
21         // and assembles the final block.
22         // Note: The block header and state database might be updated to reflect any
23         // consensus rules that happen at finalization (e.g. block rewards).
24         Finalize(c chain.Chain, header *types.BlockHeader, txs []*bc.Tx) error
25
26         // Seal generates a new block for the given input block with the local miner's
27         // seal place on top.
28         Seal(c chain.Chain, block *types.Block) (*types.Block, error)
29 }