Documentation ¶
Index ¶
- Constants
- Variables
- func MakeCache(block uint64, dir string)
- func MakeDataset(block uint64, dir string)
- func SeedHash(block uint64) []byte
- type Config
- type Cphash
- func (cphash *Cphash) APIs(chain types.ChainReader) []rpc.API
- func (cphash *Cphash) CalcKeyBlockDifficulty(chain types.KeyChainReader, time uint64, parent *types.KeyBlockHeader) *big.Int
- func (cphash *Cphash) Hashrate() float64
- func (cphash *Cphash) PowMode() uint
- func (cphash *Cphash) PrepareCandidate(chain types.KeyChainReader, candidate *types.Candidate, committeeSize int) error
- func (cphash *Cphash) SealCandidate(candidate *types.Candidate, stop <-chan struct{}) (*types.Candidate, error)
- func (cphash *Cphash) SetThreads(threads int)
- func (cphash *Cphash) Threads() int
- func (cphash *Cphash) VerifyCandidate(chain types.KeyChainReader, candidate *types.Candidate) error
- type Mode
Constants ¶
const (
MinFoundedSeconds = 5
)
Variables ¶
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
Functions ¶
func MakeDataset ¶
MakeDataset generates a new cphash dataset and optionally stores it to disk.
Types ¶
type Config ¶
type Config struct { CacheDir string CachesInMem int CachesOnDisk int DatasetDir string DatasetsInMem int DatasetsOnDisk int PowMode Mode }
Config are the configuration parameters of the cphash.
type Cphash ¶
type Cphash struct {
// contains filtered or unexported fields
}
Cphash is a pow engine based on proof-of-work implementing the cphash algorithm.
func NewFakeDelayer ¶
NewFakeDelayer creates a cphash pow 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 Cypherium pow rules.
func NewFakeFailer ¶
NewFakeFailer creates a cphash pow 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 Cypherium pow rules.
func NewFaker ¶
func NewFaker() *Cphash
NewFaker creates a cphash pow engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Cypherium pow rules.
func NewFullFaker ¶
func NewFullFaker() *Cphash
NewFullFaker creates an cphash pow engine with a full fake scheme that accepts all blocks as valid, without checking any pow rules whatsoever.
func NewShared ¶
func NewShared() *Cphash
NewShared creates a full sized cphash PoW shared between all requesters running in the same process.
func NewTester ¶
func NewTester() *Cphash
NewTester creates a small sized cphash PoW scheme useful only for testing purposes.
func (*Cphash) APIs ¶
func (cphash *Cphash) APIs(chain types.ChainReader) []rpc.API
APIs implements pow.Engine, returning the user facing RPC APIs. Currently that is empty.
func (*Cphash) CalcKeyBlockDifficulty ¶
func (cphash *Cphash) CalcKeyBlockDifficulty(chain types.KeyChainReader, time uint64, parent *types.KeyBlockHeader) *big.Int
CalcKeyBlockDifficulty 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 (*Cphash) Hashrate ¶
Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute.
func (*Cphash) PrepareCandidate ¶
func (cphash *Cphash) PrepareCandidate(chain types.KeyChainReader, candidate *types.Candidate, committeeSize int) error
Prepare implements pow.Engine, initializing the difficulty field of a candidate to conform to the cphash protocol. The changes are done inline.
func (*Cphash) SealCandidate ¶
func (cphash *Cphash) SealCandidate(candidate *types.Candidate, stop <-chan struct{}) (*types.Candidate, error)
SealCandidate implements pow.Engine, attempting to find a nonce that satisfies the candidate's difficulty requirements.
func (*Cphash) 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 (*Cphash) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*Cphash) VerifyCandidate ¶
////////////////////////////////////////////////////////////////////////////////////////////// VerifyCandidate implements pow.Engine, checking whether the given candidate satisfies the PoW difficulty requirements.