cuckoo

package
v1.9.52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2020 License: GPL-3.0, GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const PLUGIN_PATH string = "plugins/"
View Source
const PLUGIN_POST_FIX string = "_helper_for_node.so"

Variables

View Source
var (
	FrontierBlockReward       *big.Int = big.NewInt(7e+18) // Block reward in wei for successfully mining a block
	ByzantiumBlockReward      *big.Int = big.NewInt(7e+18) // Block reward in wei for successfully mining a block upward from Byzantium
	ConstantinopleBlockReward          = big.NewInt(7e+18)
)

Cuckoo proof-of-work protocol constants.

View Source
var ErrInvalidDumpMagic = errors.New("invalid dump magic")

Functions

func CalcDifficulty

func CalcDifficulty(config *params.ChainConfig, 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 DeleteTester

func DeleteTester()

func SeedHash

func SeedHash(block uint64) []byte

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API exposes cuckoo related methods for the RPC interface.

func (*API) GetHashrate

func (api *API) GetHashrate() uint64

GetHashrate returns the current hashrate for local CPU miner and remote miner.

func (*API) GetWork

func (api *API) GetWork() ([4]string, error)

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

func (api *API) SubmitHashRate(rate hexutil.Uint64, id common.Hash) bool

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

func (api *API) SubmitWork(nonce types.BlockNonce, hash common.Hash, solution string) bool

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 Block

type Block interface {
	Difficulty() *big.Int
	//	HashNoNonce() common.Hash
	Nonce() uint64
	MixDigest() common.Hash
	NumberU64() uint64
}

type Config

type Config struct {
	CacheDir     string
	CachesInMem  int
	CachesOnDisk int

	DatasetDir     string
	DatasetsInMem  int
	DatasetsOnDisk int

	PowMode Mode

	UseCuda      bool
	UseOpenCL    bool
	StrDeviceIds string
	Threads      int
	Algorithm    string
}

compatiable with cuckoo interface

type Cuckoo

type Cuckoo struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) *Cuckoo

func NewFakeDelayer added in v1.0.0

func NewFakeDelayer(seconds time.Duration) *Cuckoo

func NewFakeFailer added in v1.0.0

func NewFakeFailer(number uint64) *Cuckoo

func NewFullFaker

func NewFullFaker() *Cuckoo

func NewShared

func NewShared() *Cuckoo

NewShared() func in tests/block_tests_util.go

func NewTester

func NewTester() *Cuckoo

func (*Cuckoo) APIs

func (cuckoo *Cuckoo) APIs(chain consensus.ChainReader) []rpc.API

func (*Cuckoo) Author

func (cuckoo *Cuckoo) Author(header *types.Header) (common.Address, error)

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) Close

func (cuckoo *Cuckoo) Close() error

Close closes the exit channel to notify all backend threads exiting.

func (*Cuckoo) CuckooVerifyHeader added in v1.0.0

func (cuckoo *Cuckoo) CuckooVerifyHeader(hash []byte, nonce uint64, sol *types.BlockSolution, number uint64, targetDiff *big.Int) (ok bool)

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) Hashrate

func (cuckoo *Cuckoo) Hashrate() float64

func (*Cuckoo) InitPlugin added in v1.0.0

func (cuckoo *Cuckoo) InitPlugin() error

func (*Cuckoo) Mine

func (cuckoo *Cuckoo) Mine(block *types.Block, id int, seed uint64, abort chan struct{}, found chan *types.Block) (err error)

func (*Cuckoo) Prepare

func (cuckoo *Cuckoo) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the cuckoo protocol. The changes are done inline.

func (*Cuckoo) Seal

func (cuckoo *Cuckoo) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error

func (*Cuckoo) SealHash

func (cuckoo *Cuckoo) SealHash(header *types.Header) (hash common.Hash)

SealHash returns the hash of a block prior to it being sealed.

func (*Cuckoo) SetThreads

func (cuckoo *Cuckoo) SetThreads(threads int)

func (*Cuckoo) Sha3Solution added in v1.0.0

func (cuckoo *Cuckoo) Sha3Solution(sol *types.BlockSolution) []byte

func (*Cuckoo) Threads

func (cuckoo *Cuckoo) Threads() int

func (*Cuckoo) Verify

func (cuckoo *Cuckoo) Verify(block Block, hashNoNonce common.Hash, shareDiff *big.Int, solution *types.BlockSolution) (bool, bool, int64)

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 Cortex 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 *Cuckoo) VerifySeal(chain consensus.ChainReader, header *types.Header) error

func (*Cuckoo) VerifySolution

func (cuckoo *Cuckoo) VerifySolution(hash []byte, nonce uint32, solution *types.BlockSolution, target big.Int) (bool, common.Hash)

func (*Cuckoo) VerifyUncles

func (cuckoo *Cuckoo) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Cortex 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) Author added in v1.0.0

func (cuckoo *CuckooFake) Author(header *types.Header) (common.Address, error)

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) Finalize added in v1.0.0

func (cuckoo *CuckooFake) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, 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

type Mode

type Mode uint
const (
	ModeNormal Mode = iota
	ModeShared
	ModeTest
	ModeFake
	ModeFullFake
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL