lyra2

package
v1.1.7-unstable Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DisinflationRateQuotient = big.NewInt(249)
	DisinflationRateDivisor  = big.NewInt(250)
)
View Source
var (
	DifficultyBoundDivisor = big.NewInt(200)   // The bound divisor of the difficulty, used in the update calculations.
	MinimumDifficulty      = big.NewInt(10000) // The minimum that the difficulty may ever be.
)

Some weird constants to avoid constant memory allocs for them.

Functions

func CalcDifficulty

func CalcDifficulty(config ctypes.ChainConfigurator, time uint64, parent *types.Header) *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 GetBlockEra

func GetBlockEra(blockNum, eraLength *big.Int) *big.Int

GetBlockEra gets which "Era" a given block is within, given an era length (100,000 blocks) Returns a zero-index era number, so "Era 1": 0, "Era 2": 1, "Era 3": 2 ...

func GetBlockWinnerRewardByEra

func GetBlockWinnerRewardByEra(eraOrig *big.Int) *big.Int

GetRewardByEra gets a block reward at disinflation rate. Constants MaxBlockReward, DisinflationRateQuotient, and DisinflationRateDivisor assumed.

Types

type API

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

API exposes lyra2 related methods for the RPC interface.

func (*API) GetHashrate

func (api *API) GetHashrate() uint64

GetHashrate returns the current hashrate for local CPU miner and remote miner.

func (*API) GetWork

func (api *API) GetWork() ([4]string, error)

GetWork returns a work package for external miner.

The work package consists of 3 strings:

result[0], 32 bytes hex encoded current block header pow-hash
result[1], hex encoded header
result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
result[3], hex encoded block number

func (*API) SubmitHashRate

func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool

SubmitHashrate can be used for remote miners to submit their hash rate. This enables the node to report the combined hash rate of all miners which submit work through this node.

It accepts the miner hash rate and an identifier which must be unique between nodes.

func (*API) SubmitWork

func (api *API) SubmitWork(nonce types.BlockNonce, hash, digest common.Hash) bool

SubmitWork can be used by external miner to submit their POW solution. It returns an indication if the work was accepted. Note either an invalid solution, a stale work a non-existent work will return false.

type Lyra2

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

func New

func New(notify []string, noverify bool) *Lyra2

func NewTester

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

func (*Lyra2) APIs

func (lyra2 *Lyra2) APIs(chain consensus.ChainHeaderReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC APIs.

func (*Lyra2) Author

func (lyra2 *Lyra2) Author(header *types.Header) (common.Address, error)

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

func (*Lyra2) CalcDifficulty

func (lyra2 *Lyra2) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *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 (*Lyra2) Close

func (lyra2 *Lyra2) Close() error

func (*Lyra2) Finalize

func (lyra2 *Lyra2) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)

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

func (*Lyra2) FinalizeAndAssemble

func (lyra2 *Lyra2) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

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

func (*Lyra2) Hashrate

func (lyra2 *Lyra2) Hashrate() float64

func (*Lyra2) Prepare

func (lyra2 *Lyra2) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error

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

func (*Lyra2) Seal

func (lyra2 *Lyra2) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

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

func (*Lyra2) SealHash

func (lyra2 *Lyra2) SealHash(header *types.Header) (hash common.Hash)

SealHash returns the hash of a block prior to it being sealed.

func (*Lyra2) SetThreads

func (lyra2 *Lyra2) 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 (*Lyra2) Threads

func (lyra2 *Lyra2) Threads() int

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

func (*Lyra2) VerifyHeader

func (lyra2 *Lyra2) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error

VerifyHeader checks whether a header conforms to the consensus rules of the stock Detonus ethash and lyra2 engine.

func (*Lyra2) VerifyHeaders

func (lyra2 *Lyra2) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (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 (*Lyra2) VerifySeal

func (lyra2 *Lyra2) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the given block satisfies the PoW difficulty requirements.

func (*Lyra2) VerifyUncles

func (lyra2 *Lyra2) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Detonus ethash and lyra2 engine.

Jump to

Keyboard shortcuts

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