miner

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0, MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMaxErrCounts = 20

Functions

func ComputeVRF

func ComputeVRF(ctx context.Context, sign SignFunc, account string, worker address.Address, sigInput []byte) ([]byte, error)

func DrawRandomness

func DrawRandomness(rbase []byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)

DrawRandomness todo 在venus处理好后,这里的删除,用venus中的函数

func IsRoundWinner

func IsRoundWinner(
	ctx context.Context,
	round abi.ChainEpoch,
	account string,
	miner address.Address,
	brand types.BeaconEntry,
	mbi *types.MiningBaseInfo,
	sign SignFunc,
) (*types.ElectionProof, error)

func ReorgOps

func ReorgOps(lts func(context.Context, types.TipSetKey) (*types.TipSet, error), a, b *types.TipSet) ([]*types.TipSet, []*types.TipSet, error)

ReorgOps takes two tipsets (which can be at different heights), and walks their corresponding chains backwards one step at a time until we find a common ancestor. It then returns the respective chain segments that fork from the identified ancestor, in reverse order, where the first element of each slice is the supplied tipset, and the last element is the common ancestor.

If an error happens along the way, we return the error with nil slices. todo should move this code into store.ReorgOps. anywhere use this function should invoke store.ReorgOps todo 因依赖filecoin-ffi,暂时从venus复制的,venus处理好依赖后删除,用venus中的

Types

type IMinerManager

type IMinerManager interface {
	UpdateAddress(context.Context, int64, int64) ([]types.MinerInfo, error)
	ListAddress(context.Context) ([]types.MinerInfo, error)
	StatesForMining(context.Context, []address.Address) ([]types.MinerState, error)
	CountWinners(context.Context, []address.Address, abi.ChainEpoch, abi.ChainEpoch) ([]types.CountWinners, error)
	ListBlocks(ctx context.Context, params *types.BlocksQueryParams) ([]types.MinedBlock, error)
	WarmupForMiner(context.Context, address.Address) error
	QueryRecord(ctx context.Context, params *types.QueryRecordParams) ([]map[string]string, error)
}

type IMinerMining

type IMinerMining interface {
	Start(context.Context) error
	Stop(context.Context) error
	ManualStart(context.Context, []address.Address) error
	ManualStop(context.Context, []address.Address) error
}

type Miner

type Miner struct {
	PropagationDelaySecs uint64
	MinerOnceTimeout     time.Duration
	MpoolSelectDelaySecs uint64
	// contains filtered or unexported fields
}

func NewMiner

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

func (*Miner) CountWinners

func (m *Miner) CountWinners(ctx context.Context, addrs []address.Address, start abi.ChainEpoch, end abi.ChainEpoch) ([]types.CountWinners, error)

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) ListAddress

func (m *Miner) ListAddress(ctx context.Context) ([]types.MinerInfo, error)

func (*Miner) ListBlocks added in v1.13.0

func (m *Miner) ListBlocks(ctx context.Context, params *types.BlocksQueryParams) ([]types.MinedBlock, error)

func (*Miner) ManualStart

func (m *Miner) ManualStart(ctx context.Context, mAddrs []address.Address) error

func (*Miner) ManualStop

func (m *Miner) ManualStop(ctx context.Context, mAddrs []address.Address) error

func (*Miner) QueryRecord added in v1.13.0

func (m *Miner) QueryRecord(ctx context.Context, params *types.QueryRecordParams) ([]map[string]string, error)

func (*Miner) Start

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

func (*Miner) StatesForMining

func (m *Miner) StatesForMining(ctx context.Context, addrs []address.Address) ([]types.MinerState, error)

func (*Miner) Stop

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.

func (*Miner) SyncStatus

func (m *Miner) SyncStatus(ctx context.Context)

func (*Miner) UpdateAddress

func (m *Miner) UpdateAddress(ctx context.Context, skip, limit int64) ([]types.MinerInfo, error)

func (*Miner) WarmupForMiner

func (m *Miner) WarmupForMiner(ctx context.Context, mAddr address.Address) error

type MiningAPI

type MiningAPI interface {
	IMinerMining
	IMinerManager
}

type MiningBase

type MiningBase struct {
	TipSet     *sharedTypes.TipSet
	NullRounds abi.ChainEpoch
}

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

type MiningWpp

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

func NewWinningPoStProver

func NewWinningPoStProver(api v1.FullNode, gatewayNode *config.GatewayNode, mAddr address.Address) (*MiningWpp, error)

func (*MiningWpp) ComputeProof

func (wpp *MiningWpp) ComputeProof(ctx context.Context, ssi []builtin.ExtendedSectorInfo, rand abi.PoStRandomness, currEpoch abi.ChainEpoch, nv network.Version) ([]builtin.PoStProof, error)

func (*MiningWpp) GenerateCandidates

func (wpp *MiningWpp) GenerateCandidates(ctx context.Context, randomness abi.PoStRandomness, eligibleSectorCount uint64) ([]uint64, error)

type SignFunc

type SignFunc func(ctx context.Context, signer address.Address, accounts []string, toSign []byte, meta types.MsgMeta) (*crypto.Signature, error)

type WinningPoStProver

type WinningPoStProver interface {
	GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error)
	ComputeProof(context.Context, []builtin.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]builtin.PoStProof, error)
}

Directories

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

Jump to

Keyboard shortcuts

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