miner

package
v0.13.4-connect-self Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: GPL-3.0, LGPL-3.0 Imports: 23 Imported by: 13

README

Miner

The miner is a package inherited from go-ethereum with a large amount of functionality stripped out since it is not needed in coreth.

In go-ethereum, the miner needs to perform PoW in order to try and produce the next block. Since Avalanche does not rely on PoW in any way, the miner within Coreth is only used to produce blocks on demand.

All of the async functionality has been stripped out in favor of a much lighter weight miner implementation which takes a backend that supplies the blockchain and transaction pool and exposes the functionality to produce a new block with the contents of the transaction pool.

FinalizeAndAssemble

One nuance of the miner, is that it makes use of the call FinalizeAndAssemble from the coreth consensus engine. This callback, as hinted at in the name, performs the same work as Finalize in addition to assembling the block.

This means that whenever a verification or processing operation is added in Finalize it must be added in FinalizeAndAssemble as well to ensure that a block produced by the miner is processed in the same way by a node receiving that block, which did not produce it.

To illustrate, if nodeA produces a block and sends it to the network. When nodeB receives that block and processes it, it needs to process it and see the exact same result as nodeA. Otherwise, there could be a situation where two nodes either disagree on the validity of a block or process it differently and perform a different state transition as a result.

Documentation

Overview

Package miner implements Ethereum block creation and mining.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	BlockChain() *core.BlockChain
	TxPool() *txpool.TxPool
}

Backend wraps all methods required for mining.

type Config

type Config struct {
	Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards
}

Config is the configuration parameters of mining.

type Miner

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

func New

func New(eth Backend, config *Config, chainConfig *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, clock *mockable.Clock) *Miner

func (*Miner) GenerateBlock added in v0.5.2

func (miner *Miner) GenerateBlock(predicateContext *precompileconfig.PredicateContext) (*types.Block, error)

func (*Miner) SetEtherbase

func (miner *Miner) SetEtherbase(addr common.Address)

func (*Miner) SubscribePendingLogs added in v0.3.1

func (miner *Miner) SubscribePendingLogs(ch chan<- []*types.Log) event.Subscription

SubscribePendingLogs starts delivering logs from pending transactions to the given channel.

type TransactionsByPriceAndNonce added in v0.13.2

type TransactionsByPriceAndNonce = transactionsByPriceAndNonce

func NewTransactionsByPriceAndNonce added in v0.13.2

func NewTransactionsByPriceAndNonce(signer types.Signer, txs map[common.Address][]*txpool.LazyTransaction, baseFee *big.Int) *TransactionsByPriceAndNonce

Jump to

Keyboard shortcuts

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