poa

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidates

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

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

NewCandidates creates candidates list.

func (*Candidates) Copy

func (c *Candidates) Copy() *Candidates

Copy make a copy.

func (*Candidates) InvalidateCache

func (c *Candidates) InvalidateCache()

InvalidateCache invalidate the result cache of Pick method.

func (*Candidates) IsEndorsor

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

IsEndorsor returns whether an address is an endorsor.

func (*Candidates) Pick

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

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

func (*Candidates) Update

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 interface {
	Schedule(nowTime uint64) (newBlockTime uint64)
	IsTheTime(newBlockTime uint64) bool
	Updates(newBlockTime uint64) (updates []Proposer, score uint64)
}

Scheduler defines the interface of schedulers.

type SchedulerV1

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

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

func NewSchedulerV1

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

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

func (*SchedulerV1) IsTheTime

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

IsTheTime returns if the newBlockTime is correct for the proposer.

func (*SchedulerV1) Schedule

func (s *SchedulerV1) 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 (*SchedulerV1) Updates

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

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

type SchedulerV2

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

SchedulerV2 to schedule the time when a proposer to produce a block. V2 is for post VIP-214 stage.

func NewSchedulerV2

func NewSchedulerV2(
	addr thor.Address,
	proposers []Proposer,
	parentBlockNumber uint32,
	parentBlockTime uint64,
	seed []byte) (*SchedulerV2, error)

NewSchedulerV2 create a SchedulerV2 object. `addr` is the proposer to be scheduled. If `addr` is not listed in `proposers` or not active, an error returned.

func (*SchedulerV2) IsScheduled

func (s *SchedulerV2) IsScheduled(blockTime uint64, proposer thor.Address) bool

IsScheduled returns if the schedule(proposer, blockTime) is correct.

func (*SchedulerV2) IsTheTime

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

IsTheTime returns if the newBlockTime is correct for the proposer.

func (*SchedulerV2) Schedule

func (s *SchedulerV2) 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 (*SchedulerV2) Updates

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

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

type Seeder

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

Seeder generates seed for poa scheduler.

func NewSeeder

func NewSeeder(repo *chain.Repository) *Seeder

NewSeeder creates a seeder

func (*Seeder) Generate

func (seeder *Seeder) Generate(parentID thor.Bytes32) (seed []byte, err error)

Generate creates a seed for the given parent block's header.

Jump to

Keyboard shortcuts

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