miner

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package miner is responsible for creating valid blocks that contain valid activation transactions and transactions

Index

Constants

View Source
const AtxsPerBlockLimit = 100

AtxsPerBlockLimit indicates the maximum number of atxs a block can reference

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockBuilder

type BlockBuilder struct {
	log.Log

	//AtxPool         atxPool
	AtxDb           atxDb
	TransactionPool txPool
	// contains filtered or unexported fields
}

BlockBuilder is the struct that orchestrates the building of blocks, it is responsible for receiving hare results. referencing txs and atxs from mem pool and referencing them in the created block it is also responsible for listening to the clock and querying when a block should be created according to the block oracle

func NewBlockBuilder

func NewBlockBuilder(config Config, sgn signer, net p2p.Service, beginRoundEvent chan types.LayerID, weakCoin weakCoinProvider, orph meshProvider, hare hareResultProvider, blockOracle blockOracle, syncer syncer, projector projector, txPool txPool, atxDB atxDb, lg log.Log) *BlockBuilder

NewBlockBuilder creates a struct of block builder type.

func (*BlockBuilder) Close

func (t *BlockBuilder) Close() error

Close stops listeners and stops trying to create block in layers

func (*BlockBuilder) Start

func (t *BlockBuilder) Start() error

Start starts the process of creating a block, it listens for txs and atxs received by gossip, and starts querying block oracle when it should create a block. This function returns an error if Start was already called once

type BlockEligibilityValidator added in v0.1.15

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

BlockEligibilityValidator holds all the dependencies for validating block eligibility.

func NewBlockEligibilityValidator added in v0.1.15

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

NewBlockEligibilityValidator returns a new BlockEligibilityValidator.

func (BlockEligibilityValidator) BlockSignedAndEligible added in v0.1.15

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 Config added in v0.1.15

type Config struct {
	MinerID        types.NodeID
	Hdist          int
	AtxsPerBlock   int
	LayersPerEpoch uint16
	TxsPerBlock    int
}

Config is the block builders configuration struct

type EpochBeaconProvider added in v0.1.15

type EpochBeaconProvider struct{}

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

func (*EpochBeaconProvider) GetBeacon added in v0.1.15

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

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

type Oracle added in v0.1.15

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

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

func NewMinerBlockOracle added in v0.1.15

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

NewMinerBlockOracle returns a new Oracle.

func (*Oracle) BlockEligible added in v0.1.15

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 added in v0.1.15

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 added in v0.1.15

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

VRFValidationFunction is the VRF validation function.

Jump to

Keyboard shortcuts

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