Documentation ¶
Overview ¶
Package blakimoto provides functionalities for performing and verifying proof-of-work computation. It uses Blake2b-256 as the hash function.
Index ¶
- Variables
- func BlakeHash(headerHash []byte, nonce uint64) []byte
- func CalcDifficulty(blockHeader types.Header, parent types.Header) *big.Int
- type Blakimoto
- func (b *Blakimoto) CalcDifficulty(blockHeader types.Header, parent types.Header) *big.Int
- func (blakimoto *Blakimoto) Hashrate() float64
- func (b *Blakimoto) Prepare(chain types.ChainReader, header types.Header) error
- func (blakimoto *Blakimoto) SetFakeDelay(d time.Duration)
- func (blakimoto *Blakimoto) SetThreads(threads int)
- func (blakimoto *Blakimoto) Threads() int
- func (b *Blakimoto) VerifyHeader(header, parent types.Header, seal bool) error
- func (b *Blakimoto) VerifySeal(header types.Header) error
- type Config
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownParent indicates an unknown parent of a block ErrUnknownParent = fmt.Errorf("block's parent is unknown") // ErrFutureBlock is returned when a block's timestamp is in the future according // to the current node. ErrFutureBlock = errors.New("block in the future") // ErrInvalidNumber is returned if a block's number doesn't equal it's parent's // plus one. ErrInvalidNumber = errors.New("invalid block number") )
Functions ¶
Types ¶
type Blakimoto ¶
type Blakimoto struct {
// contains filtered or unexported fields
}
Blakimoto is a consensus engine based on proof-of-work implementing the blakimoto algorithm.
func ConfiguredBlakimoto ¶
ConfiguredBlakimoto creates an Blakimoto instance pre-configured using the engine configuration.
func (*Blakimoto) 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 (*Blakimoto) Hashrate ¶
Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute.
func (*Blakimoto) Prepare ¶
Prepare initializes the difficulty and total difficulty fields of a header to conform to the protocol
func (*Blakimoto) SetFakeDelay ¶
SetFakeDelay sets the delay duration for ModeFake
func (*Blakimoto) 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 (*Blakimoto) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*Blakimoto) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules