poa

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidates added in v1.1.5

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

Candidates holds candidates list in memory, and tends to be reused in PoA stage without querying from contract.

func NewCandidates added in v1.1.5

func NewCandidates(list []*authority.Candidate) *Candidates

NewCandidates creates candidates list.

func (*Candidates) Copy added in v1.1.5

func (c *Candidates) Copy() *Candidates

Copy make a copy.

func (*Candidates) InvalidateCache added in v1.1.5

func (c *Candidates) InvalidateCache()

InvalidateCache invalidate the result cache of Pick method.

func (*Candidates) IsEndorsor added in v1.1.5

func (c *Candidates) IsEndorsor(addr thor.Address) bool

IsEndorsor returns whether an address is an endorsor.

func (*Candidates) Pick added in v1.1.5

func (c *Candidates) Pick(state *state.State) ([]Proposer, error)

Pick picks a list of proposers, which satisfy preset conditions.

func (*Candidates) Update added in v1.1.5

func (c *Candidates) Update(addr thor.Address, active bool) bool

Update update candidate activity status, by its master address. It returns false if the given address is not a master.

type Proposer

type Proposer struct {
	Address thor.Address
	Active  bool
}

Proposer address with status.

type Scheduler

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

Scheduler to schedule the time when a proposer to produce a block.

func NewScheduler

func NewScheduler(
	addr thor.Address,
	proposers []Proposer,
	parentBlockNumber uint32,
	parentBlockTime uint64) (*Scheduler, error)

NewScheduler create a Scheduler object. `addr` is the proposer to be scheduled. If `addr` is not listed in `proposers`, an error returned.

func (*Scheduler) IsTheTime

func (s *Scheduler) IsTheTime(newBlockTime uint64) bool

IsTheTime returns if the newBlockTime is correct for the proposer.

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(nowTime uint64) (newBlockTime uint64)

Schedule to determine time of the proposer to produce a block, according to `nowTime`. `newBlockTime` is promised to be >= nowTime and > parentBlockTime

func (*Scheduler) Updates

func (s *Scheduler) Updates(newBlockTime uint64) (updates []Proposer, score uint64)

Updates returns proposers whose status are change, and the score when new block time is assumed to be newBlockTime.

Jump to

Keyboard shortcuts

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