OSDN Git Service

1513979bf511ce9578a2ceedadf94f8bfbfc40c9
[bytom/bytom.git] / protocol / consensus.go
1 package protocol
2
3 import (
4         "github.com/bytom/bytom/protocol/bc"
5         "github.com/bytom/bytom/protocol/bc/types"
6         "github.com/bytom/bytom/protocol/state"
7 )
8
9 // Casper is BFT based proof of stack consensus algorithm, it provides safety and liveness in theory
10 type CasperConsensus interface {
11
12         // Best chain return the chain containing the justified checkpoint of the largest height
13         BestChain() (uint64, bc.Hash)
14
15         // LastFinalized return the block height and block hash which is finalized ast last
16         LastFinalized() (uint64, bc.Hash)
17
18         // AuthVerification verify whether the Verification is legal.
19         AuthVerification(v *Verification) error
20
21         // ApplyBlock apply block to the consensus module
22         ApplyBlock(block *types.Block) (*Verification, error)
23
24         // Validators return the validators by specified block hash
25         Validators(blockHash *bc.Hash) ([]*state.Validator, error)
26 }