Documentation
¶
Index ¶
- Variables
- func CalcDifficulty(config ctypes.ChainConfigurator, time uint64, parent *types.Header) *big.Int
- func GetBlockEra(blockNum, eraLength *big.Int) *big.Int
- func GetBlockWinnerRewardByEra(eraOrig *big.Int) *big.Int
- type API
- type Lyra2
- func (lyra2 *Lyra2) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (lyra2 *Lyra2) Author(header *types.Header) (common.Address, error)
- func (lyra2 *Lyra2) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (lyra2 *Lyra2) Close() error
- func (lyra2 *Lyra2) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (lyra2 *Lyra2) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (lyra2 *Lyra2) Hashrate() float64
- func (lyra2 *Lyra2) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (lyra2 *Lyra2) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (lyra2 *Lyra2) SealHash(header *types.Header) (hash common.Hash)
- func (lyra2 *Lyra2) SetThreads(threads int)
- func (lyra2 *Lyra2) Threads() int
- func (lyra2 *Lyra2) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
- func (lyra2 *Lyra2) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (lyra2 *Lyra2) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error
- func (lyra2 *Lyra2) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
Constants ¶
This section is empty.
Variables ¶
var ( DisinflationRateQuotient = big.NewInt(249) DisinflationRateDivisor = big.NewInt(250) )
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 ¶
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 ¶
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 ...
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes lyra2 related methods for the RPC interface.
func (*API) GetHashrate ¶
GetHashrate returns the current hashrate for local CPU miner and remote miner.
func (*API) GetWork ¶
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 ¶
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 ¶
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 (*Lyra2) APIs ¶
func (lyra2 *Lyra2) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*Lyra2) Author ¶
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) 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) Prepare ¶
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) SetThreads ¶
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 ¶
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 ¶
VerifySeal implements consensus.Engine, checking whether the given block satisfies the PoW difficulty requirements.
func (*Lyra2) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Detonus ethash and lyra2 engine.