vote

package
v0.0.0-...-979e23b Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	IsMining() bool
	EventMux() *event.TypeMux
}

Backend wraps all methods required for voting.

type Debug

type Debug struct {
	ValidateRule func(header *types.Header) error
}

type VoteBox

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

type VoteManager

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

VoteManager will handle the vote produced by self.

func NewVoteManager

func NewVoteManager(
	eth Backend,
	db ethdb.Database,
	chainconfig *params.ChainConfig,
	chain *core.BlockChain,
	pool *VotePool,
	enableSign bool,
	blsPasswordPath, blsWalletPath string,
	engine consensus.FastFinalityPoSA,
	debug *Debug,
) (*VoteManager, error)

func (*VoteManager) UnderRules

func (voteManager *VoteManager) UnderRules(header *types.Header) bool

UnderRules checks if the produced header under the following rules: A validator must not publish two distinct votes for the same height. (Rule 1) Validators always vote for their canonical chain’s latest block. (Rule 2)

type VotePool

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

func NewVotePool

func NewVotePool(
	chain *core.BlockChain,
	engine consensus.FastFinalityPoSA,
	maxCurVoteAmountPerBlock int,
) *VotePool

func (*VotePool) FetchVoteByBlockHash

func (pool *VotePool) FetchVoteByBlockHash(blockHash common.Hash) []*types.VoteEnvelope

FetchVoteByBlockHash reads the finality votes for the provided block hash, the concurrent writers may block this function from acquiring the read lock. This function does not sleep and wait for acquiring the lock but keep polling the lock fetchRetry times and returns nil if it still cannot acquire the lock. This mechanism helps to make this function safer because we cannot control the writers and we don't want this function to block the caller.

func (*VotePool) GetVotes

func (pool *VotePool) GetVotes() []*types.VoteEnvelope

GetVotes as batch.

func (*VotePool) PutVote

func (pool *VotePool) PutVote(peer string, vote *types.VoteEnvelope)

func (*VotePool) SubscribeNewVoteEvent

func (pool *VotePool) SubscribeNewVoteEvent(ch chan<- core.NewVoteEvent) event.Subscription

type VoteSigner

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

func NewVoteSigner

func NewVoteSigner(blsPasswordPath, blsWalletPath string) (*VoteSigner, error)

func (*VoteSigner) SignVote

func (signer *VoteSigner) SignVote(vote *types.VoteEnvelope) error

Jump to

Keyboard shortcuts

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