Documentation ¶
Index ¶
- Constants
- Variables
- func BigIntToFloat(val *big.Int) float64
- func DifficultyToProb(difficulty *big.Int) float64
- func FloatToBigInt(val float64) *big.Int
- func MakeDecision(header *types.Header, colInRow [][]int, outputWord []int) (bool, int)
- func MakeDecision_Seoul(header *types.Header, colInRow [][]int, outputWord []int) (bool, int)
- func MakeLDPCDifficultyCalculator() func(time uint64, parent *types.Header) *big.Int
- func MakeLDPCDifficultyCalculatorAnnapurna() func(time uint64, parent *types.Header) *big.Int
- func MakeLDPCDifficultyCalculator_Seoul() func(time uint64, parent *types.Header) *big.Int
- func OptimizedDecoding(parameters Parameters, hashVector []int, H, rowInCol, colInRow [][]int) ([]int, []int, [][]float64)
- func OptimizedDecodingSeoul(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 RunOptimizedConcurrencyLDPC_Seoul(header *types.Header, hash []byte) (bool, []int, []int, uint64, []byte)
- func SearchLevel(difficulty *big.Int) int
- func SearchLevel_Seoul(difficulty *big.Int) int
- func SeedHash(block uint64) []byte
- func VerifyOptimizedDecoding(header *types.Header, hash []byte) (bool, []int, []int, []byte)
- func VerifyOptimizedDecodingSeoul(header *types.Header, hash []byte) (bool, []int, []int, []byte)
- type API
- type Config
- type ECC
- func (ecc *ECC) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (ecc *ECC) Author(header *types.Header) (common.Address, error)
- func (ecc *ECC) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (ecc *ECC) Close() error
- func (ecc *ECC) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (ecc *ECC) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (ecc *ECC) Hashrate() float64
- func (ecc *ECC) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (ecc *ECC) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (ecc *ECC) SealHash(header *types.Header) (hash common.Hash)
- func (ecc *ECC) SetThreads(threads int)
- func (ecc *ECC) StopRemoteSealer() error
- func (ecc *ECC) Threads() int
- func (ecc *ECC) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
- func (ecc *ECC) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan 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) // 36) // 10 ) // 36) Sensitivity = big.NewInt(8) SensitivityAnnapurna = big.NewInt(1024) // BlockGenerationTime for Seoul BlockGenerationTimeSeoul = big.NewInt(10) // 36) // 10 ) // 36) SeoulDifficulty = big.NewInt(1023) )
"github.com/cryptoecc/WorldLand/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 WorldLandBlockReward = big.NewInt(4e+18) //Block reward in wei for successfully mining a block upward from WorldLand HALVING_INTERVAL = uint64(6307200) //Block per year * 2year MATURITY_INTERVAL = uint64(3153600) //Block per year SumRewardUntilMaturity = big.NewInt(47304000) //Total supply of token until maturity MaxHalving = int64(4) )
ecc proof-of-work protocol constants.
var DynamicDifficultyCalculator = makeDifficultyCalculator
var FrontierDifficultyCalculator = calcDifficultyFrontier
Exported for fuzzing
var Table = []difficulty{}/* 381 elements not displayed */
Table is difficulty table slice
Functions ¶
func BigIntToFloat ¶
BigIntToFloat convert big int to float64
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 MakeDecision_Seoul ¶
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 OptimizedDecodingSeoul ¶
func OptimizedDecodingSeoul(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
func SearchLevel_Seoul ¶
SearchLevel return next level by using currentDifficulty of header Type of Ethereum difficulty is *bit.Int so arg is *big.int
func SeedHash ¶
// SeedHash is the seed to use for generating a verification cache and the mining // dataset.
func VerifyOptimizedDecoding ¶
VerifyOptimizedDecoding return bool, hashVector, outputword, digest which are used for validation
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 // 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:"-"` }
Config are the configuration parameters of the ethash.
type ECC ¶
type ECC struct {
// contains filtered or unexported fields
}
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.ChainHeaderReader) []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.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 (*ECC) Finalize ¶
func (ecc *ECC) 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 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.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 (*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) StopRemoteSealer ¶
StopRemoteSealer stops the remote sealer
func (*ECC) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*ECC) VerifyHeader ¶
func (ecc *ECC) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
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.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 (*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
}