blocks

package
v0.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultProofsEpoch = ^types.EpochID(0)

DefaultProofsEpoch is set such that it will never equal the current epoch

View Source
const NewBlockProtocol = "newBlock"

NewBlockProtocol is the protocol indicator for gossip blocks

Variables

This section is empty.

Functions

This section is empty.

Types

type BeaconGetter

type BeaconGetter interface {
	GetBeacon(epochNumber types.EpochID) ([]byte, error)
}

BeaconGetter gets a beacon value.

type BlockEligibilityValidator

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

BlockEligibilityValidator holds all the dependencies for validating block eligibility.

func NewBlockEligibilityValidator

func NewBlockEligibilityValidator(
	committeeSize uint32, layersPerEpoch uint32, activationDb activationDB, beaconProvider BeaconGetter,
	validateVRF VRFValidationFunction, blockDB blockDB, log log.Log) *BlockEligibilityValidator

NewBlockEligibilityValidator returns a new BlockEligibilityValidator.

func (BlockEligibilityValidator) BlockSignedAndEligible

func (v BlockEligibilityValidator) BlockSignedAndEligible(block *types.Block) (bool, error)

BlockSignedAndEligible checks that a given block is signed and eligible. It returns true with no error or false and an error that explains why validation failed.

type BlockHandler

type BlockHandler struct {
	log.Log
	// contains filtered or unexported fields
}

BlockHandler is the struct responsible for storing meta data needed to process blocks from gossip

func NewBlockHandler

func NewBlockHandler(cfg Config, m mesh, v blockValidator, lg log.Log) *BlockHandler

NewBlockHandler creates new BlockHandler

func (*BlockHandler) HandleBlock

func (bh *BlockHandler) HandleBlock(ctx context.Context, data service.GossipMessage, fetcher service.Fetcher)

HandleBlock handles blocks from gossip

func (*BlockHandler) HandleBlockData

func (bh *BlockHandler) HandleBlockData(ctx context.Context, data []byte, fetcher service.Fetcher) error

HandleBlockData handles blocks from gossip and sync

type Config

type Config struct {
	Depth       uint32
	GoldenATXID types.ATXID
}

Config defines configuration for block handler

type EpochBeaconProvider

type EpochBeaconProvider struct{}

EpochBeaconProvider holds all the dependencies for generating an epoch beacon. There are currently none.

func (*EpochBeaconProvider) GetBeacon

func (p *EpochBeaconProvider) GetBeacon(epochNumber types.EpochID) ([]byte, error)

GetBeacon returns a beacon given an epoch ID. The current implementation returns the epoch ID in byte format.

type Oracle

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

Oracle is the oracle that provides block eligibility proofs for the miner.

func NewMinerBlockOracle

func NewMinerBlockOracle(committeeSize uint32, layersPerEpoch uint32, atxDB activationDB, beaconProvider BeaconGetter, vrfSigner vrfSigner, nodeID types.NodeID, isSynced func() bool, log log.Log) *Oracle

NewMinerBlockOracle returns a new Oracle.

func (*Oracle) BlockEligible

func (bo *Oracle) BlockEligible(layerID types.LayerID) (types.ATXID, []types.BlockEligibilityProof, []types.ATXID, error)

BlockEligible returns the ATXID and list of block eligibility proofs for the given layer. It caches proofs for a single epoch and only refreshes the cache if eligibility is queried for a different epoch.

func (*Oracle) GetEligibleLayers

func (bo *Oracle) GetEligibleLayers() []types.LayerID

GetEligibleLayers returns a list of layers in which the miner is eligible for at least one block. The list is returned in arbitrary order.

type VRFValidationFunction

type VRFValidationFunction func(publicKey, message, signature []byte) bool

VRFValidationFunction is the VRF validation function.

Jump to

Keyboard shortcuts

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