Documentation ¶
Index ¶
- Constants
- Variables
- func ElectCommittee(snailchain snailReader, defaultMembers []*types.CommitteeMember, ...) *types.ElectionCommittee
- type BlockChain
- type Config
- type ElectMode
- type Election
- func (e *Election) FinalizeCommittee(block *types.Block) error
- func (e *Election) GenerateFakeSigns(fb *types.Block) ([]*types.PbftSign, error)
- func (e *Election) GetCommittee(fastNumber *big.Int) []*types.CommitteeMember
- func (e *Election) GetCommitteeById(id *big.Int) map[string]interface{}
- func (e *Election) GetCurrentCommittee() *committee
- func (e *Election) GetCurrentCommitteeNumber() *big.Int
- func (e *Election) GetGenesisCommittee() []*types.CommitteeMember
- func (e *Election) GetMemberByPubkey(members []*types.CommitteeMember, publickey []byte) *types.CommitteeMember
- func (e *Election) GetMemberFlag(members []*types.CommitteeMember, publickey []byte) uint32
- func (e *Election) IsCommitteeMember(members []*types.CommitteeMember, publickey []byte) bool
- func (e *Election) IsTIP8(fastHeadNumber *big.Int) bool
- func (e *Election) SetEngine(engine consensus.Engine)
- func (e *Election) Start() error
- func (e *Election) SubscribeElectionEvent(ch chan<- types.ElectionEvent) event.Subscription
- func (e *Election) VerifyPublicKey(fastHeight *big.Int, pubKeyByte []byte) (*types.CommitteeMember, error)
- func (e *Election) VerifySign(sign *types.PbftSign) (*types.CommitteeMember, error)
- func (e *Election) VerifySigns(signs []*types.PbftSign) ([]*types.CommitteeMember, []error)
- func (e *Election) VerifySwitchInfo(fastNumber *big.Int, info []*types.CommitteeMember) error
- type SnailBlockChain
- type SnailLightChain
Constants ¶
const ( // ElectModeEtrue for etrue ElectModeEtrue = iota // ElectModeFake for Test purpose ElectModeFake )
Variables ¶
Functions ¶
func ElectCommittee ¶
func ElectCommittee(snailchain snailReader, defaultMembers []*types.CommitteeMember, snailBeginNumber *big.Int, snailEndNumber *big.Int) *types.ElectionCommittee
ElectCommittee elect committee members from snail block.
Types ¶
type BlockChain ¶
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
func NewElection ¶
func NewElection(chainConfig *params.ChainConfig, fastBlockChain BlockChain, snailBlockChain SnailBlockChain, config Config) *Election
NewElection create election processor and load genesis committee
func NewFakeElection ¶
func NewFakeElection() *Election
NewFakeElection create fake mode election only for testing
func NewLightElection ¶
func NewLightElection(fastBlockChain BlockChain, snailBlockChain SnailBlockChain) *Election
func (*Election) FinalizeCommittee ¶ added in v0.10.1
FinalizeCommittee upddate current committee state
func (*Election) GenerateFakeSigns ¶
func (*Election) GetCommittee ¶
func (e *Election) GetCommittee(fastNumber *big.Int) []*types.CommitteeMember
GetCommittee gets committee members propose this fast block
func (*Election) GetCommitteeById ¶ added in v0.10.2
GetCommitteeById return committee info sepecified by Committee ID
func (*Election) GetCurrentCommittee ¶
func (e *Election) GetCurrentCommittee() *committee
func (*Election) GetCurrentCommitteeNumber ¶
func (*Election) GetGenesisCommittee ¶
func (e *Election) GetGenesisCommittee() []*types.CommitteeMember
func (*Election) GetMemberByPubkey ¶
func (e *Election) GetMemberByPubkey(members []*types.CommitteeMember, publickey []byte) *types.CommitteeMember
GetMemberByPubkey returns committeeMember specified by public key bytes
func (*Election) GetMemberFlag ¶
func (e *Election) GetMemberFlag(members []*types.CommitteeMember, publickey []byte) uint32
IsCommitteeMember reports whether the provided public key is in committee
func (*Election) IsCommitteeMember ¶
func (e *Election) IsCommitteeMember(members []*types.CommitteeMember, publickey []byte) bool
func (*Election) SubscribeElectionEvent ¶
func (e *Election) SubscribeElectionEvent(ch chan<- types.ElectionEvent) event.Subscription
SubscribeElectionEvent adds a channel to feed on committee change event
func (*Election) VerifyPublicKey ¶
func (e *Election) VerifyPublicKey(fastHeight *big.Int, pubKeyByte []byte) (*types.CommitteeMember, error)
VerifyPublicKey get the committee member by public key
func (*Election) VerifySign ¶
VerifySign lookup the pbft sign and return the committee member who signs it
func (*Election) VerifySigns ¶
VerifySigns verify signatures of bft committee in batches
func (*Election) VerifySwitchInfo ¶
VerifySwitchInfo verify committee members and it's state
type SnailBlockChain ¶
type SnailBlockChain interface { SnailLightChain SubscribeChainEvent(ch chan<- types.SnailChainEvent) event.Subscription GetDatabase() etruedb.Database GetFruitByFastHash(fastHash common.Hash) (*types.SnailBlock, uint64) GetBlockByNumber(number uint64) *types.SnailBlock GetFruitsHead(number uint64) []*types.SnailHeader GetHeaderByNumber(number uint64) *types.SnailHeader }
SnailBlockChain encapsulates functions required to sync a (full or fast) blockchain.
type SnailLightChain ¶
type SnailLightChain interface { // CurrentHeader retrieves the head header from the local chain. CurrentHeader() *types.SnailHeader }
SnailLightChain encapsulates functions required to synchronise a light chain.