blake3pow

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: GPL-3.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContextTimeFactor = big10
	ZoneBlockReward   = big.NewInt(5e+18)
	RegionBlockReward = new(big.Int).Mul(ZoneBlockReward, big3)
	PrimeBlockReward  = new(big.Int).Mul(RegionBlockReward, big3)
)

Blake3pow proof-of-work protocol constants.

Functions

This section is empty.

Types

type Blake3pow

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

Blake3pow is a proof-of-work consensus engine using the blake3 hash algorithm

func New

func New(config Config, notify []string, noverify bool, logger *log.Logger) *Blake3pow

New creates a full sized blake3pow PoW scheme and starts a background thread for remote mining, also optionally notifying a batch of remote services of new work packages.

func NewFakeDelayer

func NewFakeDelayer(delay time.Duration) *Blake3pow

NewFakeDelayer creates a blake3pow consensus engine with a fake PoW scheme that accepts all blocks as valid, but delays verifications by some time, though they still have to conform to the Quai consensus rules.

func NewFakeFailer

func NewFakeFailer(fail uint64) *Blake3pow

NewFakeFailer creates a blake3pow consensus engine with a fake PoW scheme that accepts all blocks as valid apart from the single one specified, though they still have to conform to the Quai consensus rules.

func NewFaker

func NewFaker() *Blake3pow

NewFaker creates a blake3pow consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Quai consensus rules.

func NewFullFaker

func NewFullFaker() *Blake3pow

NewFullFaker creates an blake3pow consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.

func NewShared

func NewShared() *Blake3pow

NewShared creates a full sized blake3pow PoW shared between all requesters running in the same process.

func NewTester

func NewTester(notify []string, noverify bool) *Blake3pow

NewTester creates a small sized blake3pow PoW scheme useful only for testing purposes.

func (*Blake3pow) Author

func (blake3pow *Blake3pow) Author(header *types.WorkObject) (common.Address, error)

Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.

func (*Blake3pow) CalcDifficulty

func (blake3pow *Blake3pow) CalcDifficulty(chain consensus.ChainHeaderReader, parent *types.WorkObjectHeader, expansionNum uint8) *big.Int

CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have when created at time given the parent block's time and difficulty.

func (*Blake3pow) CalcOrder

func (blake3pow *Blake3pow) CalcOrder(header *types.WorkObject) (*big.Int, int, error)

CalcOrder returns the order of the block within the hierarchy of chains

func (*Blake3pow) CalcRank added in v0.29.0

func (blake3pow *Blake3pow) CalcRank(chain consensus.GenesisReader, header *types.WorkObject) (int, error)

CalcRank returns the rank of the block within the hierarchy of chains, this determines the level of the interlink

func (*Blake3pow) CheckIfValidWorkShare added in v0.29.0

func (blake3pow *Blake3pow) CheckIfValidWorkShare(workShare *types.WorkObjectHeader) bool

func (*Blake3pow) ComputePowHash added in v0.29.0

func (blake3pow *Blake3pow) ComputePowHash(header *types.WorkObjectHeader) (common.Hash, error)

func (*Blake3pow) ComputePowLight

func (blake3pow *Blake3pow) ComputePowLight(header *types.WorkObjectHeader) (common.Hash, common.Hash)

func (*Blake3pow) DeltaLogS

func (blake3pow *Blake3pow) DeltaLogS(chain consensus.GenesisReader, header *types.WorkObject) *big.Int

func (*Blake3pow) Finalize

func (blake3pow *Blake3pow) Finalize(chain consensus.ChainHeaderReader, header *types.WorkObject, state *state.StateDB)

Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state on the header

func (*Blake3pow) FinalizeAndAssemble

func (blake3pow *Blake3pow) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.WorkObject, state *state.StateDB, txs []*types.Transaction, uncles []*types.WorkObjectHeader, etxs []*types.Transaction, subManifest types.BlockManifest, receipts []*types.Receipt) (*types.WorkObject, error)

FinalizeAndAssemble implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.

func (*Blake3pow) IntrinsicLogS

func (blake3pow *Blake3pow) IntrinsicLogS(powHash common.Hash) *big.Int

IntrinsicLogS returns the logarithm of the intrinsic entropy reduction of a PoW hash

func (*Blake3pow) IsDomCoincident

func (blake3pow *Blake3pow) IsDomCoincident(chain consensus.ChainHeaderReader, header *types.WorkObject) bool

func (*Blake3pow) NodeLocation added in v0.29.0

func (blake3pow *Blake3pow) NodeLocation() common.Location

NodeLocation returns the location of the node

func (*Blake3pow) Prepare

func (blake3pow *Blake3pow) Prepare(chain consensus.ChainHeaderReader, header *types.WorkObject, parent *types.WorkObject) error

Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the blake3pow protocol. The changes are done inline.

func (*Blake3pow) Seal

func (blake3pow *Blake3pow) Seal(header *types.WorkObject, results chan<- *types.WorkObject, stop <-chan struct{}) error

Seal implements consensus.Engine, attempting to find a nonce that satisfies the header's difficulty requirements.

func (*Blake3pow) SetThreads

func (blake3pow *Blake3pow) SetThreads(threads int)

SetThreads updates the number of mining threads currently enabled. Calling this method does not start mining, only sets the thread count. If zero is specified, the miner will use all cores of the machine. Setting a thread count below zero is allowed and will cause the miner to idle, without any work being done.

func (*Blake3pow) Threads

func (blake3pow *Blake3pow) Threads() int

Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!

func (*Blake3pow) TotalLogPhS

func (blake3pow *Blake3pow) TotalLogPhS(header *types.WorkObject) *big.Int

func (*Blake3pow) TotalLogS

func (blake3pow *Blake3pow) TotalLogS(chain consensus.GenesisReader, header *types.WorkObject) *big.Int

TotalLogS() returns the total entropy reduction if the chain since genesis to the given header

func (*Blake3pow) UncledLogS added in v0.29.0

func (blake3pow *Blake3pow) UncledLogS(block *types.WorkObject) *big.Int

func (*Blake3pow) UncledSubDeltaLogS added in v0.29.0

func (blake3pow *Blake3pow) UncledSubDeltaLogS(chain consensus.GenesisReader, header *types.WorkObject) *big.Int

func (*Blake3pow) VerifyHeader

func (blake3pow *Blake3pow) VerifyHeader(chain consensus.ChainHeaderReader, header *types.WorkObject) error

VerifyHeader checks whether a header conforms to the consensus rules of the stock Quai blake3pow engine.

func (*Blake3pow) VerifyHeaders

func (blake3pow *Blake3pow) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.WorkObject) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications.

func (*Blake3pow) VerifySeal added in v0.20.0

func (blake3pow *Blake3pow) VerifySeal(header *types.WorkObjectHeader) (common.Hash, error)

VerifySeal returns the PowHash and the verifySeal output

func (*Blake3pow) VerifyUncles

func (blake3pow *Blake3pow) VerifyUncles(chain consensus.ChainReader, block *types.WorkObject) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Quai blake3pow engine.

func (*Blake3pow) WorkShareLogS added in v0.29.0

func (blake3pow *Blake3pow) WorkShareLogS(wo *types.WorkObject) (*big.Int, error)

type Config

type Config struct {
	PowMode Mode

	DurationLimit *big.Int

	GasCeil uint64

	NodeLocation common.Location

	MinDifficulty *big.Int

	// When set, notifications sent by the remote sealer will
	// be block header JSON objects instead of work package arrays.
	NotifyFull bool

	Log *log.Logger `toml:"-"`
	// Number of threads to mine on if mining
	NumThreads int
}

Config are the configuration parameters of the blake3pow.

type Mode

type Mode uint

Mode defines the type and amount of PoW verification a blake3pow engine makes.

const (
	ModeNormal Mode = iota
	ModeShared
	ModeTest
	ModeFake
	ModeFullFake
)

Jump to

Keyboard shortcuts

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