Documentation
¶
Index ¶
- func CreateVote(privKey crypto.PrivKey, attHeader xchain.AttestHeader, block xchain.Block) (*types.Vote, error)
- func GenEmptyStateFile(path string) error
- type Voter
- func (v *Voter) AvailableCount() int
- func (v *Voter) GetAvailable() []*types.Vote
- func (v *Voter) LocalAddress() common.Address
- func (v *Voter) SetCommitted(ctx context.Context, headers []*types.AttestHeader) error
- func (v *Voter) SetProposed(ctx context.Context, headers []*types.AttestHeader) error
- func (v *Voter) Start(ctx context.Context)
- func (v *Voter) TrimBehind(minsByChain map[xchain.ChainVersion]uint64) int
- func (v *Voter) UpdateValidatorSet(valset *vtypes.ValidatorSetResponse) error
- func (v *Voter) Vote(attHeader xchain.AttestHeader, block xchain.Block, allowSkip bool) error
- func (v *Voter) WaitDone()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateVote ¶
func CreateVote(privKey crypto.PrivKey, attHeader xchain.AttestHeader, block xchain.Block) (*types.Vote, error)
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 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, asyncAbort chan<- error, ) (*Voter, error)
LoadVoter returns a new attester with state loaded from disk.
func (*Voter) AvailableCount ¶
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 ¶
SetCommitted sets the votes as committed. Persisting the result to disk.
func (*Voter) SetProposed ¶
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[xchain.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) UpdateValidatorSet ¶
func (v *Voter) UpdateValidatorSet(valset *vtypes.ValidatorSetResponse) error
UpdateValidatorSet caches whether this voter is a validator in the provided set.