Documentation ¶
Index ¶
- func CreateVote(privKey crypto.PrivKey, block xchain.Block) (*types.Vote, error)
- func GenEmptyStateFile(path string) error
- type IsValDetector
- type Voter
- func (v *Voter) AvailableCount() int
- func (v *Voter) GetAvailable() []*types.Vote
- func (v *Voter) LocalAddress() common.Address
- func (v *Voter) SetCommitted(headers []*types.BlockHeader) error
- func (v *Voter) SetProposed(headers []*types.BlockHeader) error
- func (v *Voter) Start(ctx context.Context)
- func (v *Voter) TrimBehind(minsByChain map[types.ChainVersion]uint64) int
- func (v *Voter) UpdateValidators(valset []abci.ValidatorUpdate)
- func (v *Voter) Vote(block xchain.Block, allowSkip bool) error
- func (v *Voter) WaitDone()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateVote ¶
CreateVote creates a vote for the given block.
func GenEmptyStateFile ¶
GenEmptyStateFile generates an empty attester state file at the given path. This must be called before LoadVoter.
Types ¶
type IsValDetector ¶ added in v0.1.4
type IsValDetector func(valset []abci.ValidatorUpdate) (isValidator bool, statusChanged bool)
IsValDetector is a function that detects if the "IsValidator" status changes for subsequent validator updates.
func NewIsValDetector ¶ added in v0.1.4
func NewIsValDetector(localAddr common.Address) IsValDetector
type Voter ¶
type Voter struct {
// contains filtered or unexported fields
}
Voter implements the types.Voter interface. It is responsible for creating and persisting votes. The goal is to ensure "all blocks are votes for".
Note Start must be called only once on startup. GetAvailable, SetProposed, and SetCommitted are thread safe, but must be called after Start.
func LoadVoter ¶
func LoadVoter(privKey crypto.PrivKey, path string, provider xchain.Provider, deps types.VoterDeps, network netconf.Network, ) (*Voter, error)
LoadVoter returns a new attester with state loaded from disk.
func (*Voter) AvailableCount ¶ added in v0.1.3
AvailableCount returns the number of available votes.
func (*Voter) GetAvailable ¶
GetAvailable returns a copy of all the available votes.
func (*Voter) LocalAddress ¶
func (*Voter) SetCommitted ¶
func (v *Voter) SetCommitted(headers []*types.BlockHeader) error
SetCommitted sets the votes as committed. Persisting the result to disk.
func (*Voter) SetProposed ¶
func (v *Voter) SetProposed(headers []*types.BlockHeader) error
SetProposed sets the votes as proposed.
func (*Voter) Start ¶
Start starts runners that attest to each source chain. It does not block, it returns immediately.
func (*Voter) TrimBehind ¶
func (v *Voter) TrimBehind(minsByChain map[types.ChainVersion]uint64) int
TrimBehind trims all available and proposed votes that are behind the vote window thresholds (map[chainID]offset) and returns the number that was deleted.
func (*Voter) UpdateValidators ¶ added in v0.1.4
func (v *Voter) UpdateValidators(valset []abci.ValidatorUpdate)
UpdateValidators caches whether this voter is a validator in the provided set.