Versions in this module Expand all Collapse all v1 v1.0.0 Jul 13, 2019 Changes in this version + var ErrFutureBlock = errors.New("block in the future") + var ErrInvalidDifficulty = errors.New("non-positive difficulty") + var ErrInvalidMixDigest = errors.New("invalid mix digest") + var ErrInvalidNumber = errors.New("invalid block number") + var ErrInvalidPoW = errors.New("invalid proof-of-work") + var ErrNoMiningWork = errors.New("no mining work available yet") + var ErrNotRemote = errors.New("is not remote mining") + var ErrPreTime = errors.New("parent time is smaller than time for CalculateDifficulty") + var ErrPrunedAncestor = errors.New("pruned ancestor") + var ErrUnknownAncestor = errors.New("unknown ancestor") + type ChainReader interface + Config func() *config.QuarkChainConfig + CurrentHeader func() types.IHeader + GetBlock func(hash common.Hash) types.IBlock + GetHeader func(hash common.Hash) types.IHeader + GetHeaderByNumber func(number uint64) types.IHeader + type CommonEngine struct + func NewCommonEngine(spec MiningSpec, diffCalc DifficultyCalculator, remote bool) *CommonEngine + func (c *CommonEngine) Author(header types.IHeader) (account.Address, error) + func (c *CommonEngine) CalcDifficulty(chain ChainReader, time uint64, parent types.IHeader) (*big.Int, error) + func (c *CommonEngine) Close() error + func (c *CommonEngine) FindNonce(work MiningWork, results chan<- MiningResult, stop <-chan struct{}) error + func (c *CommonEngine) GetWork() (*MiningWork, error) + func (c *CommonEngine) Name() string + func (c *CommonEngine) Seal(chain ChainReader, block types.IBlock, results chan<- types.IBlock, ...) error + func (c *CommonEngine) SetThreads(threads int) + func (c *CommonEngine) SetWork(block types.IBlock, results chan<- types.IBlock) + func (c *CommonEngine) SubmitWork(nonce uint64, hash, digest common.Hash) bool + func (c *CommonEngine) VerifyHeader(chain ChainReader, header types.IHeader, seal bool) error + func (c *CommonEngine) VerifyHeaders(chain ChainReader, headers []types.IHeader, seals []bool) (chan<- struct{}, <-chan error) + func (c *CommonEngine) VerifySeal(chain ChainReader, header types.IHeader, adjustedDiff *big.Int) error + type DifficultyCalculator interface + CalculateDifficulty func(parent types.IHeader, time uint64) (*big.Int, error) + type Engine interface + Author func(header types.IHeader) (account.Address, error) + CalcDifficulty func(chain ChainReader, time uint64, parent types.IHeader) (*big.Int, error) + Close func() error + Finalize func(chain ChainReader, header types.IHeader, state *state.StateDB, ...) (types.IBlock, error) + GetWork func() (*MiningWork, error) + Prepare func(chain ChainReader, header types.IHeader) error + Seal func(chain ChainReader, block types.IBlock, results chan<- types.IBlock, ...) error + SetThreads func(threads int) + SubmitWork func(nonce uint64, hash, digest common.Hash) bool + VerifyHeader func(chain ChainReader, header types.IHeader, seal bool) error + VerifyHeaders func(chain ChainReader, headers []types.IHeader, seals []bool) (chan<- struct{}, <-chan error) + VerifySeal func(chain ChainReader, header types.IHeader, adjustedDiff *big.Int) error + type EthDifficultyCalculator struct + AdjustmentCutoff uint32 + AdjustmentFactor uint32 + MinimumDifficulty *big.Int + func (c *EthDifficultyCalculator) CalculateDifficulty(parent types.IHeader, time uint64) (*big.Int, error) + type FakeEngine struct + Difficulty *big.Int + Err error + FakeDelay time.Duration + NumberToFail uint64 + func (e *FakeEngine) Author(header types.IHeader) (account.Address, error) + func (e *FakeEngine) CalcDifficulty(chain ChainReader, time uint64, parent types.IHeader) (*big.Int, error) + func (e *FakeEngine) Close() error + func (e *FakeEngine) Finalize(chain ChainReader, header types.IHeader, state *state.StateDB, ...) (types.IBlock, error) + func (e *FakeEngine) GetWork() (*MiningWork, error) + func (e *FakeEngine) Prepare(chain ChainReader, header types.IHeader) error + func (e *FakeEngine) Seal(chain ChainReader, block types.IBlock, results chan<- types.IBlock, ...) error + func (e *FakeEngine) SetThreads(threads int) + func (e *FakeEngine) SubmitWork(nonce uint64, hash, digest common.Hash) bool + func (e *FakeEngine) VerifyHeader(chain ChainReader, header types.IHeader, seal bool) error + func (e *FakeEngine) VerifyHeaders(chain ChainReader, headers []types.IHeader, seals []bool) (chan<- struct{}, <-chan error) + func (e *FakeEngine) VerifySeal(chain ChainReader, header types.IHeader, adjustedDiff *big.Int) error + type MiningResult struct + Digest common.Hash + Nonce uint64 + Result []byte + type MiningSpec struct + HashAlgo func(result *ShareCache) error + Name string + VerifySeal func(chain ChainReader, header types.IHeader, adjustedDiff *big.Int) error + type MiningWork struct + Difficulty *big.Int + HeaderHash common.Hash + Number uint64 + type PoW interface + FindNonce func(work MiningWork, results chan<- MiningResult, stop <-chan struct{}) error + Name func() string + type ShareCache struct + Digest []byte + Hash []byte + Height uint64 + Nonce uint64 + Result []byte + Seed []byte