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 MakeCache(block uint64, dir string)
- func MakeDataset(block uint64, dir string)
- func SeedHash(block uint64) []byte
- type API
- type Config
- type Ethash
- func (ethash *Ethash) APIs(chain consensus.ChainReader) []rpc.API
- func (ethash *Ethash) Author(header *types.Header) (common.Address, error)
- func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (ethash *Ethash) Close() error
- func (ethash *Ethash) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (ethash *Ethash) Hashrate() float64
- func (ethash *Ethash) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash)
- func (ethash *Ethash) SetThreads(threads int)
- func (ethash *Ethash) Threads() int
- func (ethash *Ethash) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (ethash *Ethash) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ( FrontierBlockReward = new(big.Int).Mul(big.NewInt(1e+18), big.NewInt(9028)) // Block reward in wei for successfully mining a block ByzantiumBlockReward = new(big.Int).Mul(big.NewInt(1e+18), big.NewInt(2500)) // Block reward in wei for successfully mining a block upward from Byzantium ConstantinopleBlockReward = new(big.Int).Mul(big.NewInt(1e+18), big.NewInt(1000)) // Block reward in wei for successfully mining a block upward from Constantinople )
Ethash proof-of-work protocol constants.
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 MakeCache ¶
MakeCache generates a new ethash cache and optionally stores it to disk.
func MakeDataset ¶
MakeDataset generates a new ethash dataset and optionally stores it to disk.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes ethash 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] - 32 bytes hex encoded seed hash used for DAG
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.