election

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2020 License: GPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommittee     = errors.New("get committee failed")
	ErrInvalidMember = errors.New("invalid committee member")
	ErrInvalidSwitch = errors.New("invalid switch block info")
)

Functions

This section is empty.

Types

type Config

type Config interface {
	GetNodeType() bool
}

type Election

type Election struct {
	// contains filtered or unexported fields
}

func NewElection

func NewElection(fastBlockChain *core.BlockChain, 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 (*Election) GenerateFakeSigns

func (e *Election) GenerateFakeSigns(fb *types.Block) ([]*types.PbftSign, error)

func (*Election) GetCommittee

func (e *Election) GetCommittee(fastNumber *big.Int) []*types.CommitteeMember

GetCommittee gets committee members propose this fast block

func (*Election) GetCommitteeById

func (e *Election) GetCommitteeById(id *big.Int) map[string]interface{}

GetCommitteeById return committee info sepecified by Committee ID

func (*Election) GetCurrentCommittee

func (e *Election) GetCurrentCommittee() *committee

func (*Election) GetGenesisCommittee

func (e *Election) GetGenesisCommittee() []*types.CommitteeMember

func (*Election) GetMemberByPubkey

func (e *Election) GetMemberByPubkey(members []*types.CommitteeMember, pubKey []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) Start

func (e *Election) Start() error

Start load current committ and starts election processing

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

func (e *Election) VerifySign(sign *types.PbftSign) (*types.CommitteeMember, error)

VerifySign lookup the pbft sign and return the committee member who signs it

func (*Election) VerifySigns

func (e *Election) VerifySigns(signs []*types.PbftSign) ([]*types.CommitteeMember, []error)

VerifySigns verify signatures of bft committee in batches

func (*Election) VerifySwitchInfo

func (e *Election) VerifySwitchInfo(fastNumber *big.Int, info []*types.CommitteeMember) error

VerifySwitchInfo verify committee members and it's state

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL