Documentation ¶
Index ¶
- Variables
- type API
- type Blake3pow
- func New(config Config, notify []string, noverify bool) *Blake3pow
- func NewFakeDelayer(delay time.Duration) *Blake3pow
- func NewFakeFailer(fail uint64) *Blake3pow
- func NewFaker() *Blake3pow
- func NewFullFaker() *Blake3pow
- func NewShared() *Blake3pow
- func NewTester(notify []string, noverify bool) *Blake3pow
- func (blake3pow *Blake3pow) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (blake3pow *Blake3pow) Author(header *types.Header) (common.Address, error)
- func (blake3pow *Blake3pow) CalcDifficulty(chain consensus.ChainHeaderReader, parent *types.Header) *big.Int
- func (blake3pow *Blake3pow) CalcOrder(header *types.Header) (*big.Int, int, error)
- func (blake3pow *Blake3pow) Close() error
- func (blake3pow *Blake3pow) ComputePowLight(header *types.Header) (common.Hash, common.Hash)
- func (blake3pow *Blake3pow) DeltaLogS(header *types.Header) *big.Int
- func (blake3pow *Blake3pow) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (blake3pow *Blake3pow) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (blake3pow *Blake3pow) Hashrate() float64
- func (blake3pow *Blake3pow) IntrinsicLogS(powHash common.Hash) *big.Int
- func (blake3pow *Blake3pow) IsDomCoincident(chain consensus.ChainHeaderReader, header *types.Header) bool
- func (blake3pow *Blake3pow) Prepare(chain consensus.ChainHeaderReader, header *types.Header, parent *types.Header) error
- func (blake3pow *Blake3pow) Seal(header *types.Header, results chan<- *types.Header, stop <-chan struct{}) error
- func (blake3pow *Blake3pow) SetThreads(threads int)
- func (blake3pow *Blake3pow) SubmitHashrate(rate hexutil.Uint64, id common.Hash) bool
- func (blake3pow *Blake3pow) Threads() int
- func (blake3pow *Blake3pow) TotalLogPhS(header *types.Header) *big.Int
- func (blake3pow *Blake3pow) TotalLogS(header *types.Header) *big.Int
- func (blake3pow *Blake3pow) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error
- func (blake3pow *Blake3pow) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (chan<- struct{}, <-chan error)
- func (blake3pow *Blake3pow) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Config
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ( ContextTimeFactor = big10 ZoneBlockReward = big.NewInt(5e+18) RegionBlockReward = new(big.Int).Mul(ZoneBlockReward, big3) PrimeBlockReward = new(big.Int).Mul(RegionBlockReward, big3) )
Blake3pow proof-of-work protocol constants.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes blake3pow related methods for the RPC interface.
func (*API) Gblake3powrate ¶
Gblake3powrate 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 result[3] - hex encoded block number
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 Blake3pow ¶
type Blake3pow struct {
// contains filtered or unexported fields
}
Blake3pow is a proof-of-work consensus engine using the blake3 hash algorithm
func New ¶
New creates a full sized blake3pow PoW scheme and starts a background thread for remote mining, also optionally notifying a batch of remote services of new work packages.
func NewFakeDelayer ¶
NewFakeDelayer creates a blake3pow consensus 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 Quai consensus rules.
func NewFakeFailer ¶
NewFakeFailer creates a blake3pow consensus 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 Quai consensus rules.
func NewFaker ¶
func NewFaker() *Blake3pow
NewFaker creates a blake3pow consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Quai consensus rules.
func NewFullFaker ¶
func NewFullFaker() *Blake3pow
NewFullFaker creates an blake3pow consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewShared ¶
func NewShared() *Blake3pow
NewShared creates a full sized blake3pow PoW shared between all requesters running in the same process.
func NewTester ¶
NewTester creates a small sized blake3pow PoW scheme useful only for testing purposes.
func (*Blake3pow) APIs ¶
func (blake3pow *Blake3pow) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*Blake3pow) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*Blake3pow) CalcDifficulty ¶
func (blake3pow *Blake3pow) CalcDifficulty(chain consensus.ChainHeaderReader, 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 (*Blake3pow) CalcOrder ¶
CalcOrder returns the order of the block within the hierarchy of chains
func (*Blake3pow) ComputePowLight ¶
func (*Blake3pow) Finalize ¶
func (blake3pow *Blake3pow) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)
Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state on the header
func (*Blake3pow) FinalizeAndAssemble ¶
func (blake3pow *Blake3pow) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, etxs []*types.Transaction, subManifest types.BlockManifest, receipts []*types.Receipt) (*types.Block, error)
FinalizeAndAssemble implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.
func (*Blake3pow) Hashrate ¶
Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute. Note the returned hashrate includes local hashrate, but also includes the total hashrate of all remote miner.
func (*Blake3pow) IntrinsicLogS ¶
IntrinsicLogS returns the logarithm of the intrinsic entropy reduction of a PoW hash
func (*Blake3pow) IsDomCoincident ¶
func (*Blake3pow) Prepare ¶
func (blake3pow *Blake3pow) Prepare(chain consensus.ChainHeaderReader, header *types.Header, parent *types.Header) error
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the blake3pow protocol. The changes are done inline.
func (*Blake3pow) Seal ¶
func (blake3pow *Blake3pow) Seal(header *types.Header, results chan<- *types.Header, stop <-chan struct{}) error
Seal implements consensus.Engine, attempting to find a nonce that satisfies the header's difficulty requirements.
func (*Blake3pow) 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 (*Blake3pow) 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 (*Blake3pow) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*Blake3pow) TotalLogPhS ¶
func (*Blake3pow) TotalLogS ¶
TotalLogS() returns the total entropy reduction if the chain since genesis to the given header
func (*Blake3pow) VerifyHeader ¶
func (blake3pow *Blake3pow) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Quai blake3pow engine.
func (*Blake3pow) VerifyHeaders ¶
func (blake3pow *Blake3pow) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (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 (*Blake3pow) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Quai blake3pow engine.
type Config ¶
type Config struct { PowMode Mode DurationLimit *big.Int GasCeil uint64 // When set, notifications sent by the remote sealer will // be block header JSON objects instead of work package arrays. NotifyFull bool Log *log.Logger `toml:"-"` }
Config are the configuration parameters of the blake3pow.