Documentation
¶
Index ¶
- Variables
- func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int
- func CuckooFinalize()
- func CuckooFindSolutions(hash []byte, nonce uint64) (status_code uint32, ret [][]uint32)
- func CuckooInit(threads uint32)
- func CuckooInitialize(threads uint32, nInstances uint32)
- func CuckooSolve(hash *byte, hash_len int, nonce uint64, result *uint32, result_len *uint32, ...) byte
- func CuckooVerify(hash *byte, hash_len int, nonce uint64, result *uint32, diff *byte, ...) byte
- func CuckooVerifyHeader(hash []byte, nonce uint64, sol *types.BlockSolution) (ok bool, sha3hash common.Hash)
- func CuckooVerifyHeaderNonceAndSolutions(hash []byte, nonce uint64, result *uint32) int
- func DeleteTester()
- func SeedHash(block uint64) []byte
- func Sha3Solution(sol *types.BlockSolution) []byte
- type API
- type Block
- type Config
- type Cuckoo
- func (cuckoo *Cuckoo) APIs(chain consensus.ChainReader) []rpc.API
- func (cuckoo *Cuckoo) Author(header *types.Header) (common.Address, error)
- func (cuckoo *Cuckoo) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (cuckoo *Cuckoo) Close() error
- func (cuckoo *Cuckoo) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (cuckoo *Cuckoo) Hashrate() float64
- func (cuckoo *Cuckoo) InitOnce()
- func (cuckoo *Cuckoo) Mine(block *types.Block, id int, seed uint64, abort chan struct{}, ...)
- func (cuckoo *Cuckoo) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (cuckoo *Cuckoo) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (cuckoo *Cuckoo) SealHash(header *types.Header) (hash common.Hash)
- func (cuckoo *Cuckoo) SetThreads(threads int)
- func (cuckoo *Cuckoo) Threads() int
- func (cuckoo *Cuckoo) Verify(block Block, hashNoNonce common.Hash, shareDiff *big.Int, ...) (bool, bool, int64)
- func (cuckoo *Cuckoo) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (cuckoo *Cuckoo) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (cuckoo *Cuckoo) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (cuckoo *Cuckoo) VerifySolution(hash []byte, nonce uint32, solution *types.BlockSolution, target big.Int) (bool, common.Hash)
- func (cuckoo *Cuckoo) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type CuckooFake
- func (cuckoo *CuckooFake) APIs(chain consensus.ChainReader) []rpc.API
- func (cuckoo *CuckooFake) Author(header *types.Header) (common.Address, error)
- func (cuckoo *CuckooFake) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (cuckoo *CuckooFake) Close() error
- func (cuckoo *CuckooFake) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (cuckoo *CuckooFake) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (cuckoo *CuckooFake) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (cuckoo *CuckooFake) SealHash(header *types.Header) (hash common.Hash)
- func (cuckoo *CuckooFake) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (cuckoo *CuckooFake) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (cuckoo *CuckooFake) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (cuckoo *CuckooFake) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ( FrontierBlockReward *big.Int = big.NewInt(8e+18) // Block reward in wei for successfully mining a block ByzantiumBlockReward *big.Int = big.NewInt(8e+18) // Block reward in wei for successfully mining a block upward from Byzantium )
Cuckoo proof-of-work protocol constants.
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
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 CuckooFinalize ¶
func CuckooFinalize()
func CuckooFindSolutions ¶
func CuckooInit ¶
func CuckooInit(threads uint32)
func CuckooInitialize ¶
func CuckooSolve ¶
func CuckooVerify ¶
func CuckooVerifyHeader ¶
func DeleteTester ¶
func DeleteTester()
func Sha3Solution ¶
func Sha3Solution(sol *types.BlockSolution) []byte
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes cuckoo 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
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 { CacheDir string CachesInMem int CachesOnDisk int DatasetDir string DatasetsInMem int DatasetsOnDisk int PowMode Mode }
compatiable with cuckoo interface
type Cuckoo ¶
type Cuckoo struct {
// contains filtered or unexported fields
}
func NewFakeDelayer ¶ added in v1.0.0
func NewFakeFailer ¶ added in v1.0.0
func NewFullFaker ¶
func NewFullFaker() *Cuckoo
func (*Cuckoo) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*Cuckoo) CalcDifficulty ¶
func (cuckoo *Cuckoo) 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 (*Cuckoo) Finalize ¶
func (cuckoo *Cuckoo) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.
func (*Cuckoo) Prepare ¶
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the cuckoo protocol. The changes are done inline.
func (*Cuckoo) SetThreads ¶
func (*Cuckoo) VerifyHeader ¶
func (cuckoo *Cuckoo) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum cuckoo engine.
func (*Cuckoo) VerifyHeaders ¶
func (cuckoo *Cuckoo) 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 (*Cuckoo) VerifySeal ¶
func (*Cuckoo) VerifySolution ¶
func (*Cuckoo) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Ethereum cuckoo engine.
type CuckooFake ¶ added in v1.0.0
type CuckooFake struct { }
func NewFaker ¶
func NewFaker() *CuckooFake
func (*CuckooFake) APIs ¶ added in v1.0.0
func (cuckoo *CuckooFake) APIs(chain consensus.ChainReader) []rpc.API
func (*CuckooFake) CalcDifficulty ¶ added in v1.0.0
func (cuckoo *CuckooFake) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
func (*CuckooFake) Close ¶ added in v1.0.0
func (cuckoo *CuckooFake) Close() error
func (*CuckooFake) Prepare ¶ added in v1.0.0
func (cuckoo *CuckooFake) Prepare(chain consensus.ChainReader, header *types.Header) error
func (*CuckooFake) Seal ¶ added in v1.0.0
func (cuckoo *CuckooFake) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
func (*CuckooFake) SealHash ¶ added in v1.0.0
func (cuckoo *CuckooFake) SealHash(header *types.Header) (hash common.Hash)
func (*CuckooFake) VerifyHeader ¶ added in v1.0.0
func (cuckoo *CuckooFake) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
func (*CuckooFake) VerifyHeaders ¶ added in v1.0.0
func (cuckoo *CuckooFake) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
func (*CuckooFake) VerifySeal ¶ added in v1.0.0
func (cuckoo *CuckooFake) VerifySeal(chain consensus.ChainReader, header *types.Header) error
func (*CuckooFake) VerifyUncles ¶ added in v1.0.0
func (cuckoo *CuckooFake) VerifyUncles(chain consensus.ChainReader, block *types.Block) error