miner

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {
	// MineDuration tracks the duration of each mine() cycle, including empty runs.
	MineDuration prometheus.Histogram

	// BlocksMined counts successfully finalized synthetic EVM blocks.
	BlocksMined prometheus.Counter

	// TransactionsMined counts total transactions committed across all mined blocks.
	TransactionsMined prometheus.Counter

	// ErrorsTotal counts mine() cycles that returned an error.
	ErrorsTotal prometheus.Counter

	// LatestBlock tracks the block number of the most recently finalized synthetic EVM block.
	LatestBlock prometheus.Gauge
}

Metrics holds Prometheus collectors for the ethrpc miner.

func NewMetrics

NewMetrics registers ethrpc miner metrics against the given registerer.

func NewNopMetrics

func NewNopMetrics() *Metrics

NewNopMetrics returns a Metrics instance backed by a throwaway registry. Use in tests where metric values are not asserted.

type Miner

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

Miner periodically claims completed mempool entries and commits them as a synthetic EVM block. Business logic for EVM data construction lives here; the Store only performs raw SQL operations.

func New

func New(store Store, chainID, gasLimit uint64, maxTxsPerBlock int, interval time.Duration, metrics *Metrics, logger *zap.Logger) *Miner

New creates a new Miner.

func (*Miner) Start

func (m *Miner) Start(ctx context.Context) error

Start runs the mining loop until ctx is canceled.

type Store

type Store interface {
	// NewBlock opens a DB transaction and acquires an exclusive lock on the
	// evm_state row, serializing concurrent miners. The lock is held until
	// Finalize or Abort is called on the returned PendingBlock.
	NewBlock(ctx context.Context, chainID uint64) (ethrpc.PendingBlock, error)
}

Store is the narrow data-access interface the miner needs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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