election

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: GPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ElectModeEtrue for etrue
	ElectModeEtrue = iota
	// ElectModeFake for Test purpose
	ElectModeFake
)

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 ElectMode

type ElectMode uint

type Election

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

func NewElection

func NewElection(fastBlockChain *core.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 (*Election) FinalizeCommittee added in v0.10.1

func (e *Election) FinalizeCommittee(block *types.Block) error

FinalizeCommittee upddate current committee state

func (*Election) GenerateFakeSigns

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

func (*Election) GetComitteeById

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

GetComitteeById return committee info sepecified by Committee ID

func (*Election) GetCommittee

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

GetCommittee gets committee members propose this fast block

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, 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) SetEngine

func (e *Election) SetEngine(engine consensus.Engine)

SetEngine set election backend consesus

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

type SnailBlockChain

type SnailBlockChain interface {
	SnailLightChain

	// CurrentBlock retrieves the head block from the local chain.
	CurrentBlock() *types.SnailBlock

	SubscribeChainEvent(ch chan<- types.ChainSnailEvent) event.Subscription

	GetDatabase() etruedb.Database

	GetFruitByFastHash(fastHash common.Hash) (*types.SnailBlock, uint64)

	GetBlockByNumber(number uint64) *types.SnailBlock
}

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.

Jump to

Keyboard shortcuts

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