Documentation
¶
Index ¶
- Constants
- Variables
- func BigIntToFloat(val *big.Int) float64
- func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int
- func DifficultyToProb(difficulty *big.Int) float64
- func FloatToBigInt(val float64) *big.Int
- func MakeDecision(header *types.Header, colInRow [][]int, outputWord []int) bool
- func MakeLDPCDifficultyCalculator() func(time uint64, parent *types.Header) *big.Int
- func OptimizedDecoding(parameters Parameters, hashVector []int, H, rowInCol, colInRow [][]int) ([]int, []int, [][]float64)
- func ProbToDifficulty(miningProb float64) *big.Int
- func RunOptimizedConcurrencyLDPC(header *types.Header, hash []byte) (bool, []int, []int, uint64, []byte)
- func SearchLevel(difficulty *big.Int) int
- func SeedHash(block *types.Block) []byte
- func VerifyOptimizedDecoding(header *types.Header, hash []byte) (bool, []int, []int, []byte)
- type API
- type Config
- type ECC
- func (ecc *ECC) APIs(chain consensus.ChainReader) []rpc.API
- func (ecc *ECC) Author(header *types.Header) (common.Address, error)
- func (ecc *ECC) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (ecc *ECC) Close() error
- func (ecc *ECC) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...)
- func (ecc *ECC) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (ecc *ECC) Hashrate() float64
- func (ecc *ECC) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (ecc *ECC) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (ecc *ECC) SealHash(header *types.Header) (hash common.Hash)
- func (ecc *ECC) SetThreads(threads int)
- func (ecc *ECC) Threads() int
- func (ecc *ECC) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (ecc *ECC) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (ecc *ECC) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (ecc *ECC) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Mode
- type Parameters
Constants ¶
const ( BigInfinity = 1000000.0 Inf = 64.0 MaxNonce = 1<<32 - 1 )
Parameters for matrix and seed
Variables ¶
var ( MinimumDifficulty = ProbToDifficulty(Table[0].miningProb) BlockGenerationTime = big.NewInt(36) Sensitivity = big.NewInt(8) )
"github.com/ethereum/go-ethereum/consensus/ethash/consensus.go" Some weird constants to avoid constant memory allocs for them.
var ( FrontierBlockReward = big.NewInt(5e+18) // Block reward in wei for successfully mining a block ByzantiumBlockReward = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium ConstantinopleBlockReward = big.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Constantinople )
ecc proof-of-work protocol constants.
var Table = []difficulty{}/* 381 elements not displayed */
Table is difficulty table slice
Functions ¶
func BigIntToFloat ¶
BigIntToFloat convert big int to float64
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 DifficultyToProb ¶
DifficultyToProb convert difficulty to probability of table
func FloatToBigInt ¶
FloatToBigInt convert float64 to big integer
func MakeDecision ¶
MakeDecision check outputWord is valid or not using colInRow
func MakeLDPCDifficultyCalculator ¶
MakeLDPCDifficultyCalculator calculate difficulty using difficulty table
func OptimizedDecoding ¶
func OptimizedDecoding(parameters Parameters, hashVector []int, H, rowInCol, colInRow [][]int) ([]int, []int, [][]float64)
OptimizedDecoding return hashVector, outputWord, LRrtl
func ProbToDifficulty ¶
ProbToDifficulty convert probability to difficulty of header
func RunOptimizedConcurrencyLDPC ¶
func RunOptimizedConcurrencyLDPC(header *types.Header, hash []byte) (bool, []int, []int, uint64, []byte)
RunOptimizedConcurrencyLDPC use goroutine for mining block
func SearchLevel ¶
SearchLevel return next level by using currentDifficulty of header Type of Ethereum difficulty is *bit.Int so arg is *big.int
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes ecc related methods for the RPC interface.
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 Mode
}
Config are the configuration parameters of the ethash.
type ECC ¶
type ECC struct {
// contains filtered or unexported fields
}
func New ¶
New creates a full sized ethash 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 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() *ECC
NewFaker creates a 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() *ECC
NewFullFaker creates an ethash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func (*ECC) APIs ¶
func (ecc *ECC) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*ECC) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*ECC) CalcDifficulty ¶
func (ecc *ECC) CalcDifficulty(chain consensus.ChainReader, 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 (*ECC) Finalize ¶
func (ecc *ECC) Finalize(chain consensus.ChainReader, 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 and assembling the block.
func (*ECC) FinalizeAndAssemble ¶
func (*ECC) 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 (*ECC) Prepare ¶
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the ecc protocol. The changes are done inline.
func (*ECC) Seal ¶
func (ecc *ECC) Seal(chain consensus.ChainReader, 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 (*ECC) 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 (*ECC) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*ECC) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum ecc engine.
func (*ECC) VerifyHeaders ¶
func (ecc *ECC) VerifyHeaders(chain consensus.ChainReader, 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 (*ECC) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the given block satisfies the PoW difficulty requirements.
func (*ECC) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Ethereum ecc engine.
type Parameters ¶
type Parameters struct {
// contains filtered or unexported fields
}