miner

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0, MIT Imports: 34 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestMiner

func NewTestMiner(nextCh <-chan MineReq, addr address.Address) func(v1api.FullNode, gen.WinningPoStProver) *Miner

Types

type MineReq added in v0.5.0

type MineReq struct {
	InjectNulls abi.ChainEpoch
	Done        func(bool, abi.ChainEpoch, error)
}

type Miner

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

Miner encapsulates the mining processes of the system.

Refer to the godocs on mineOne and mine methods for more detail.

func NewMiner

func NewMiner(api v1api.FullNode, epp gen.WinningPoStProver, addr address.Address, sf *slashfilter.SlashFilter, j journal.Journal) *Miner

NewMiner instantiates a miner with a concrete WinningPoStProver and a miner address (which can be different from the worker's address).

func (*Miner) Address added in v0.3.0

func (m *Miner) Address() address.Address

Address returns the address of the miner.

func (*Miner) GetBestMiningCandidate

func (m *Miner) GetBestMiningCandidate(ctx context.Context) (*MiningBase, error)

GetBestMiningCandidate implements the fork choice rule from a miner's perspective.

It obtains the current chain head (HEAD), and compares it to the last tipset we selected as our mining base (LAST). If HEAD's weight is larger than LAST's weight, it selects HEAD to build on. Else, it selects LAST.

func (*Miner) Start added in v0.3.0

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

Start starts the mining operation. It spawns a goroutine and returns immediately. Start is not idempotent.

func (*Miner) Stop added in v0.3.0

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

Stop stops the mining operation. It is not idempotent, and multiple adjacent calls to Stop will fail.

type MiningBase

type MiningBase struct {
	TipSet      *types.TipSet
	ComputeTime time.Time
	NullRounds  abi.ChainEpoch
}

MiningBase is the tipset on top of which we plan to construct our next block. Refer to godocs on GetBestMiningCandidate.

Jump to

Keyboard shortcuts

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