import (
"github.com/vapor/chain"
+ "github.com/vapor/common"
"github.com/vapor/protocol/bc"
"github.com/vapor/protocol/bc/types"
)
-// Engine is an algorithm agnostic consensus engine.
-type Engine interface {
-
- // VerifySeal checks whether the crypto seal on a header is valid according to
- // the consensus rules of the given engine.
- VerifySeal(c chain.Chain, header *types.BlockHeader) error
-
- // Prepare initializes the consensus fields of a block header according to the
- // rules of a particular engine. The changes are executed inline.
- Prepare(c chain.Chain, header *types.BlockHeader) error
+type AddressBalance struct {
+ Address string
+ Balance int64
+}
- // Finalize runs any post-transaction state modifications (e.g. block rewards)
- // and assembles the final block.
- // Note: The block header and state database might be updated to reflect any
- // consensus rules that happen at finalization (e.g. block rewards).
- Finalize(c chain.Chain, header *types.BlockHeader, txs []*bc.Tx) error
+type DelegateInterface interface {
+ ConsensusName() string
+}
- // Seal generates a new block for the given input block with the local miner's
- // seal place on top.
- Seal(c chain.Chain, block *types.Block) (*types.Block, error)
+// Engine is an algorithm agnostic consensus engine.
+type Engine interface {
+ Init(c chain.Chain, delegateNumber, intervalTime, blockHeight uint64, blockHash bc.Hash) error
+ Finish() error
+ IsMining(address common.Address, t uint64) (interface{}, error)
+ ProcessRegister(delegateAddress string, delegateName string, hash bc.Hash, height uint64) bool
+ ProcessVote(voterAddress string, delegates []string, hash bc.Hash, height uint64) bool
+ ProcessCancelVote(voterAddress string, delegates []string, hash bc.Hash, height uint64) bool
+ UpdateAddressBalance(addressBalance []AddressBalance)
+ CheckBlockHeader(header types.BlockHeader) error
+ CheckBlock(block types.Block, fIsCheckDelegateInfo bool) error
+ IsValidBlockCheckIrreversibleBlock(height uint64, hash bc.Hash) error
+ GetOldBlockHeight() uint64
+ GetOldBlockHash() bc.Hash
}