blocks

package
v0.2.9-beta.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const NewBlockProtocol = "newBlock"

NewBlockProtocol is the protocol indicator for gossip blocks.

Variables

View Source
var ErrMinerHasNoATXInPreviousEpoch = errors.New("miner has no ATX in previous epoch")

ErrMinerHasNoATXInPreviousEpoch is returned when miner has no ATXs in previous epoch.

Functions

This section is empty.

Types

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, beacons beaconCollector,
	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 {
	// contains filtered or unexported fields
}

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

func NewBlockHandler

func NewBlockHandler(fetcher system.Fetcher, m mesh, v blockValidator, opts ...Opt) *BlockHandler

NewBlockHandler creates new BlockHandler.

func (*BlockHandler) HandleBlock

func (bh *BlockHandler) HandleBlock(ctx context.Context, _ peer.ID, msg []byte) pubsub.ValidationResult

HandleBlock handles blocks from gossip.

func (*BlockHandler) HandleBlockData

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

HandleBlockData handles blocks from gossip and sync.

type Config

type Config struct {
	MaxExceptions int
}

Config defines configuration for block handler.

type Opt added in v1.0.0

type Opt func(b *BlockHandler)

Opt for configuring BlockHandler.

func WithLogger added in v1.0.0

func WithLogger(logger log.Log) Opt

WithLogger defines logger for BlockHandler.

func WithMaxExceptions

func WithMaxExceptions(max int) Opt

WithMaxExceptions defines max allowed exceptions in a block.

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 system.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, list of block eligibility proofs for the given layer and the active set of the epoch. It caches proofs for a single epoch and only refreshes the cache if eligibility is queried for a different epoch.

type VRFValidationFunction

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

VRFValidationFunction is the VRF validation function.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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