Documentation
¶
Index ¶
- func CreateVote(privKey crypto.PrivKey, block xchain.Block) (*types.Vote, error)
- func GenEmptyStateFile(path string) error
- type Voter
- func (a *Voter) GetAvailable() []*types.Vote
- func (a *Voter) LocalAddress() common.Address
- func (a *Voter) SetCommitted(headers []*types.BlockHeader) error
- func (a *Voter) SetProposed(headers []*types.BlockHeader) error
- func (a *Voter) Start(ctx context.Context)
- func (a *Voter) TrimBehind(thresholds map[uint64]uint64) int
- func (a *Voter) Vote(block xchain.Block, allowSkip bool) error
- func (a *Voter) WaitDone()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateVote ¶
CreateVote creates an 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, chains map[uint64]string, ) (*Voter, error)
LoadVoter returns a new attester with state loaded from disk.
func (*Voter) GetAvailable ¶
GetAvailable returns a copy of all the available votes.
func (*Voter) LocalAddress ¶
func (*Voter) SetCommitted ¶
func (a *Voter) SetCommitted(headers []*types.BlockHeader) error
SetCommitted sets the votes as committed. Persisting the result to disk.
func (*Voter) SetProposed ¶
func (a *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 ¶
TrimBehind trims all votes that are behind the vote window thresholds (map[chainID]height) and returns the number that was deleted.