OSDN Git Service

Add the implementation for dppos
[bytom/vapor.git] / consensus / consensus / consensus.go
1 package consensus
2
3 import (
4         "github.com/vapor/chain"
5         "github.com/vapor/common"
6         "github.com/vapor/protocol/bc"
7         "github.com/vapor/protocol/bc/types"
8 )
9
10 type AddressBalance struct {
11         Address string
12         Balance int64
13 }
14
15 type DelegateInterface interface {
16         ConsensusName() string
17 }
18
19 // Engine is an algorithm agnostic consensus engine.
20 type Engine interface {
21         Init(c chain.Chain, delegateNumber, intervalTime, blockHeight uint64, blockHash bc.Hash) error
22         Finish() error
23         IsMining(address common.Address, t uint64) (interface{}, error)
24         ProcessRegister(delegateAddress string, delegateName string, hash bc.Hash, height uint64) bool
25         ProcessVote(voterAddress string, delegates []string, hash bc.Hash, height uint64) bool
26         ProcessCancelVote(voterAddress string, delegates []string, hash bc.Hash, height uint64) bool
27         UpdateAddressBalance(addressBalance []AddressBalance)
28         CheckBlockHeader(header types.BlockHeader) error
29         CheckBlock(block types.Block, fIsCheckDelegateInfo bool) error
30         IsValidBlockCheckIrreversibleBlock(height uint64, hash bc.Hash) error
31         GetOldBlockHeight() uint64
32         GetOldBlockHash() bc.Hash
33 }