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 (b *Blakimoto) Prepare(chain types.ChainReaderFactory, header types.Header) error
- func (blakimoto *Blakimoto) SetFakeDelay(d time.Duration)
- 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) 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) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules