tasks

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CoinbaseFlags is added to the coinbase script of a generated block
	// and is used to monitor BIP16 support as well as blocks that are
	// generated via btcd.
	CoinbaseFlags = "/P2SH/jaxnet/"

	// MiningRoundTimeWindow defines how much time would be taken by one miming round.
	// Mining round - it is a calculations cycle, during which miner do not accepts new tasks
	// (does not react on changes in blocks configuration).
	// During this time window the miner is trying to solve the PoC for beacon/shards(s) chain blocks,
	// that has been received on a last update.
	MiningRoundTimeWindow = time.Millisecond * 150
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context added in v0.2.0

type Context struct {
	Task       *MinerTask
	Result     *MinerResult
	Ticker     *time.Ticker
	Nonce      uint32
	ExtraNonce uint64
}

Context represents the mining process state. It is used for storing and updating the context of the current mining round.

type MinerResult

type MinerResult struct {
	BitcoinBlock btcdwire.MsgBlock
	BeaconBlock  wire.MsgBlock
	ShardsBlocks map[common.ShardID]*wire.MsgBlock

	NumHashes uint64
	// contains filtered or unexported fields
}

MinerResult represents result of the mining process. Could contain mined beacon chain block and/or one or more mined shards blocks.

func NewMinerResult

func NewMinerResult() MinerResult

func (*MinerResult) AppendShardSolution

func (mr *MinerResult) AppendShardSolution(id common.ShardID, shardBlock *wire.MsgBlock, solvedBeaconBlock *wire.MsgBlock)

func (*MinerResult) ContainsMinedBeaconBlock

func (mr *MinerResult) ContainsMinedBeaconBlock() bool

func (*MinerResult) ContainsMinedBitcoinBlock added in v0.2.0

func (mr *MinerResult) ContainsMinedBitcoinBlock() bool

func (*MinerResult) ContainsMinedBlocks added in v0.2.0

func (mr *MinerResult) ContainsMinedBlocks(btcMiningEnabled bool) bool

func (*MinerResult) ContainsMinedShardsBlocks

func (mr *MinerResult) ContainsMinedShardsBlocks() bool

func (*MinerResult) SetBeaconSolution added in v0.2.0

func (mr *MinerResult) SetBeaconSolution(block *wire.MsgBlock)

func (*MinerResult) SetBitcoinSolution added in v0.2.0

func (mr *MinerResult) SetBitcoinSolution(block *btcdwire.MsgBlock)

type MinerTask

type MinerTask struct {
	BeaconBlock       wire.MsgBlock
	BeaconBlockHeight int64
	BeaconHash        chainhash.Hash

	// Represents target of the beacon chain.
	// (this is the main target of the mining process).
	BeaconTarget big.Int

	// Represents targets of the shards.
	// The slice is supposed to be sorted in descendant order.
	// Sorting is needed for the mining process efficiency:
	// during mining, on each hash mined, it is applied to the shards targets,
	// from smallest one to the biggest one.
	// The generated hash would not be applied to the next shard target
	// in case if current one does not suite the generated hash.
	ShardsTargets    []ShardTask
	ShardsCandidates map[common.ShardID]*ShardTask

	BitcoinBlock              btcdwire.MsgBlock
	BitcoinBlockHeight        int64
	BitcoinBlockCoinbaseParts utils.BitcoinBlockCoinbaseParts

	ShareTarget big.Int

	BlockFlags MinerTaskBlockFlags
	// contains filtered or unexported fields
}

MinerTask represents a miner task. Each task is an independent unit of data that could be stored/processed on its own. It is designed to not to share any data with any other components, so it can be safely transferred through the goroutines.

func (*MinerTask) BitcoinBlockTarget added in v0.2.0

func (task *MinerTask) BitcoinBlockTarget() big.Int

func (*MinerTask) IsNewer added in v0.2.0

func (task *MinerTask) IsNewer(prev *MinerTask, btcMode bool) bool

func (*MinerTask) UpdateShardsMerkleRoot added in v0.2.0

func (task *MinerTask) UpdateShardsMerkleRoot(extraNonce uint64)

func (*MinerTask) UpdateTimeAndMerkleRoots added in v0.2.0

func (task *MinerTask) UpdateTimeAndMerkleRoots(timestamp time.Time, extraNonce uint64)

func (*MinerTask) Validate added in v0.2.0

func (task *MinerTask) Validate() error

type MinerTaskBlockFlags added in v0.2.0

type MinerTaskBlockFlags uint8
const (
	BitcoinFlag MinerTaskBlockFlags = 1 << iota
	BeaconFlag
)

type ShardTask

type ShardTask struct {
	ID             common.ShardID
	BlockCandidate wire.MsgBlock
	BlockHeight    int64
	Target         big.Int
}

Jump to

Keyboard shortcuts

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