Documentation
¶
Overview ¶
Package frkhash implements the frkhash proof-of-work consensus engine.
Index ¶
- Constants
- 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 API
- type Config
- type Frkhash
- func (frkhash *Frkhash) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (frkhash *Frkhash) Author(header *types.Header) (common.Address, error)
- func (frkhash *Frkhash) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (frkhash *Frkhash) Close() error
- func (frkhash *Frkhash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (frkhash *Frkhash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (frkhash *Frkhash) Hashrate() float64
- func (frkhash *Frkhash) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (frkhash *Frkhash) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (frkhash *Frkhash) SealHash(header *types.Header) (hash common.Hash)
- func (frkhash *Frkhash) SetThreads(threads int)
- func (frkhash *Frkhash) Threads() int
- func (frkhash *Frkhash) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
- func (frkhash *Frkhash) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (frkhash *Frkhash) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
Constants ¶
const ( ModeNormal ethash.Mode = iota ModeTest ModeFake ModeFullFake )
Variables ¶
var ( FrontierBlockReward = big.NewInt(8e+18) // Block reward in wei for successfully mining a block ByzantiumBlockReward = big.NewInt(4e+18) // Block reward in wei for successfully mining a block upward from Byzantium ConstantinopleBlockReward = big.NewInt(4e+18) // Block reward in wei for successfully mining a block upward from Constantinople )
Frkhash proof-of-work protocol constants.
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
var FrontierDifficultyCalulator = calcDifficultyFrontier
Exported for fuzzing
var HomesteadDifficultyCalulator = 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 API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes frkhash 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.
type Config ¶
type Config struct { PowMode ethash.Mode // 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:"-"` XIP5Block *uint64 `toml:"-"` }
Config are the configuration parameters of the frkhash.
type Frkhash ¶
type Frkhash struct {
// contains filtered or unexported fields
}
Frkhash is a consensus engine based on proof-of-work implementing the frkhash algorithm.
func New ¶
New creates a full sized frkhash PoW scheme and starts a background thread for remote mining, also optionally notifying a batch of remote services of new work packages.
func NewFakeDelayer ¶
NewFakeDelayer creates a frkhash 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 frkhash 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() *Frkhash
NewFaker creates a frkhash 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() *Frkhash
NewFullFaker creates an frkhash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewShared ¶
func NewShared() *Frkhash
NewShared creates a full sized frkhash PoW shared between all requesters running in the same process.
func NewTester ¶
NewTester creates a small sized frkhash PoW scheme useful only for testing purposes.
func (*Frkhash) APIs ¶
func (frkhash *Frkhash) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*Frkhash) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*Frkhash) CalcDifficulty ¶
func (frkhash *Frkhash) 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 (*Frkhash) Finalize ¶
func (frkhash *Frkhash) 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 (*Frkhash) FinalizeAndAssemble ¶
func (frkhash *Frkhash) 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 (*Frkhash) Hashrate ¶
Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute. Note the returned hashrate includes local hashrate, but also includes the total hashrate of all remote miner.
func (*Frkhash) Prepare ¶
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the frkhash protocol. The changes are done inline.
func (*Frkhash) Seal ¶
func (frkhash *Frkhash) 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 (*Frkhash) 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 (*Frkhash) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*Frkhash) VerifyHeader ¶
func (frkhash *Frkhash) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum frkhash engine.
func (*Frkhash) VerifyHeaders ¶
func (frkhash *Frkhash) 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 (*Frkhash) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Ethereum frkhash engine.