Documentation ¶
Index ¶
- Constants
- Variables
- func CalcEligibleLayer(epochNumber types.EpochID, layersPerEpoch uint32, vrfSig []byte) types.LayerID
- func GetNumEligibleSlots(weight, totalWeight uint64, committeeSize uint32, layersPerEpoch uint32) (uint32, error)
- func SerializeVRFMessage(beacon types.Beacon, epoch types.EpochID, counter uint32) ([]byte, error)
- type Config
- type DB
- func (db *DB) AddProposal(ctx context.Context, p *types.Proposal) error
- func (db *DB) Close()
- func (db *DB) Get(hash []byte) ([]byte, error)
- func (db *DB) GetProposal(id types.ProposalID) (*types.Proposal, error)
- func (db *DB) GetProposals(pids []types.ProposalID) ([]*types.Proposal, error)
- func (db *DB) HasProposal(id types.ProposalID) bool
- func (db *DB) LayerProposalIDs(lid types.LayerID) ([]types.ProposalID, error)
- func (db *DB) LayerProposals(lid types.LayerID) ([]*types.Proposal, error)
- type Handler
- type Opt
- type Validator
Constants ¶
const NewProposalProtocol = "newProposal"
NewProposalProtocol is the protocol indicator for gossip Proposals.
Variables ¶
var ErrZeroTotalWeight = errors.New("zero total weight not allowed")
ErrZeroTotalWeight is returned when zero total epoch weight is used when calculating eligible slots.
Functions ¶
func CalcEligibleLayer ¶
func CalcEligibleLayer(epochNumber types.EpochID, layersPerEpoch uint32, vrfSig []byte) types.LayerID
CalcEligibleLayer calculates the eligible layer from the VRF signature.
Types ¶
type Config ¶
type Config struct { LayerSize uint32 LayersPerEpoch uint32 GoldenATXID types.ATXID MaxExceptions int EligibilityValidator eligibilityValidator }
Config defines configuration for the handler.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB holds all data for proposals.
func NewProposalDB ¶
NewProposalDB returns a new DB for proposals.
func (*DB) AddProposal ¶
AddProposal adds a proposal to the database.
func (*DB) GetProposal ¶
GetProposal retrieves a proposal from the database.
func (*DB) GetProposals ¶
GetProposals retrieves multiple proposals from the database.
func (*DB) HasProposal ¶
func (db *DB) HasProposal(id types.ProposalID) bool
HasProposal returns true if the database has the Proposal specified by the ProposalID and false otherwise.
func (*DB) LayerProposalIDs ¶
LayerProposalIDs retrieves all proposal IDs from the layer specified by layer ID.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler processes Proposal from gossip and, if deems it valid, propagates it to peers.
func NewHandler ¶
func NewHandler(f system.Fetcher, bc system.BeaconCollector, db atxDB, m meshDB, p proposalDB, opts ...Opt) *Handler
NewHandler creates new Handler.
func (*Handler) HandleBallotData ¶
HandleBallotData handles Ballot data from gossip and sync.
func (*Handler) HandleProposal ¶
func (h *Handler) HandleProposal(ctx context.Context, _ peer.ID, msg []byte) pubsub.ValidationResult
HandleProposal is the gossip receiver for Proposal.
type Opt ¶
type Opt func(h *Handler)
Opt for configuring Handler.
func WithGoldenATXID ¶
WithGoldenATXID defines the golden ATXID.
func WithLayerPerEpoch ¶
WithLayerPerEpoch defines the number of layers per epoch.
func WithLayerSize ¶
WithLayerSize defines the average number of proposal per layer.
func WithMaxExceptions ¶
WithMaxExceptions defines max allowed exceptions in a ballot.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates the eligibility of a Ballot. the validation focuses on eligibility only and assumes the Ballot to be valid otherwise.
func NewEligibilityValidator ¶
func NewEligibilityValidator( avgLayerSize, layersPerEpoch uint32, db atxDB, bc system.BeaconCollector, m meshDB, lg log.Log) *Validator
NewEligibilityValidator returns a new EligibilityValidator.