Documentation ¶
Overview ¶
Package ethash implements the ethash proof-of-work consensus engine.
Index ¶
- Variables
- func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int
- func CalcDifficultyFrontierU256(time uint64, parent *types.Header) *big.Int
- func CalcDifficultyHomesteadU256(time uint64, parent *types.Header) *big.Int
- func MakeDifficultyCalculatorU256(bombDelay *big.Int) func(time uint64, parent *types.Header) *big.Int
- type Ethash
- func (ethash *Ethash) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (ethash *Ethash) Author(header *types.Header) (common.Address, error)
- func (ethash *Ethash) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (ethash *Ethash) Close() error
- func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (ethash *Ethash) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash)
- func (ethash *Ethash) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error
- func (ethash *Ethash) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (chan<- struct{}, <-chan error)
- func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
Constants ¶
This section is empty.
Variables ¶
var ( FrontierBlockReward = uint256.NewInt(5e+18) // Block reward in wei for successfully mining a block ByzantiumBlockReward = uint256.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium ConstantinopleBlockReward = uint256.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Constantinople )
Ethash proof-of-work protocol constants.
var DynamicDifficultyCalculator = makeDifficultyCalculator
var FrontierDifficultyCalculator = calcDifficultyFrontier
Exported for fuzzing
var HomesteadDifficultyCalculator = calcDifficultyHomestead
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 CalcDifficultyFrontierU256 ¶
CalcDifficultyFrontierU256 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. The calculation uses the Frontier rules.
func CalcDifficultyHomesteadU256 ¶
CalcDifficultyHomesteadU256 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. The calculation uses the Homestead rules.
func MakeDifficultyCalculatorU256 ¶
func MakeDifficultyCalculatorU256(bombDelay *big.Int) func(time uint64, parent *types.Header) *big.Int
MakeDifficultyCalculatorU256 creates a difficultyCalculator with the given bomb-delay. the difficulty is calculated with Byzantium rules, which differs from Homestead in how uncles affect the calculation
Types ¶
type Ethash ¶
type Ethash struct {
// contains filtered or unexported fields
}
Ethash is a consensus engine based on proof-of-work implementing the ethash algorithm.
func NewFakeDelayer ¶
NewFakeDelayer creates a ethash 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 Ethereum consensus rules.
func NewFakeFailer ¶
NewFakeFailer creates a ethash 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 Ethereum consensus rules.
func NewFaker ¶
func NewFaker() *Ethash
NewFaker creates an ethash consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Ethereum consensus rules.
func NewFullFaker ¶
func NewFullFaker() *Ethash
NewFullFaker creates an ethash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func (*Ethash) APIs ¶
func (ethash *Ethash) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning no APIs as ethash is an empty shell in the post-merge world.
func (*Ethash) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*Ethash) CalcDifficulty ¶
func (ethash *Ethash) 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 (*Ethash) Finalize ¶
func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal)
Finalize implements consensus.Engine, accumulating the block and uncle rewards.
func (*Ethash) FinalizeAndAssemble ¶
func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error)
FinalizeAndAssemble implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.
func (*Ethash) Prepare ¶
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the ethash protocol. The changes are done inline.
func (*Ethash) Seal ¶
func (ethash *Ethash) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal generates a new sealing request for the given input block and pushes the result into the given channel. For the ethash engine, this method will just panic as sealing is not supported anymore.
func (*Ethash) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum ethash engine.
func (*Ethash) VerifyHeaders ¶
func (ethash *Ethash) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (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 (*Ethash) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Ethereum ethash engine.