Documentation ¶
Overview ¶
Package entrustash implements the entrustash proof-of-work consensus engine.
Index ¶
- Variables
- func AccumulateRewards(state *state.StateDB, header *types.Header, uncles []*types.Header)
- func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int
- func MakeCache(block uint64, dir string)
- func MakeDataset(block uint64, dir string)
- func SeedHash(block uint64) []byte
- type Entrustash
- func New(cachedir string, cachesinmem, cachesondisk int, dagdir string, ...) *Entrustash
- func NewFakeDelayer(delay time.Duration) *Entrustash
- func NewFakeFailer(fail uint64) *Entrustash
- func NewFaker() *Entrustash
- func NewFullFaker() *Entrustash
- func NewShared() *Entrustash
- func NewTester() *Entrustash
- func (entrustash *Entrustash) APIs(chain consensus.ChainReader) []rpc.API
- func (entrustash *Entrustash) Author(header *types.Header) (common.Address, error)
- func (entrustash *Entrustash) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (entrustash *Entrustash) Hashrate() float64
- func (entrustash *Entrustash) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (entrustash *Entrustash) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (entrustash *Entrustash) SetThreads(threads int)
- func (entrustash *Entrustash) Threads() int
- func (entrustash *Entrustash) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (entrustash *Entrustash) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (entrustash *Entrustash) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (entrustash *Entrustash) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
Functions ¶
func AccumulateRewards ¶
AccumulateRewards credits the coinbase of the given block with the mining reward. The total reward consists of the static block reward and rewards for included uncles. The coinbase of each uncle block is also rewarded. TODO (karalabe): Move the chain maker into this package and make this private!
func 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. TODO (karalabe): Move the chain maker into this package and make this private!
func MakeDataset ¶
MakeDataset generates a new entrustash dataset and optionally stores it to disk.
Types ¶
type Entrustash ¶
type Entrustash struct {
// contains filtered or unexported fields
}
Entrustash is a consensus engine based on proot-of-work implementing the entrustash algorithm.
func New ¶
func New(cachedir string, cachesinmem, cachesondisk int, dagdir string, dagsinmem, dagsondisk int) *Entrustash
New creates a full sized entrustash PoW scheme.
func NewFakeDelayer ¶
func NewFakeDelayer(delay time.Duration) *Entrustash
NewFakeDelayer creates a entrustash 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 Trustmachine consensus rules.
func NewFakeFailer ¶
func NewFakeFailer(fail uint64) *Entrustash
NewFakeFailer creates a entrustash 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 Trustmachine consensus rules.
func NewFaker ¶
func NewFaker() *Entrustash
NewFaker creates a entrustash consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Trustmachine consensus rules.
func NewFullFaker ¶
func NewFullFaker() *Entrustash
NewFullFaker creates an entrustash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewShared ¶
func NewShared() *Entrustash
NewShared creates a full sized entrustash PoW shared between all requesters running in the same process.
func NewTester ¶
func NewTester() *Entrustash
NewTester creates a small sized entrustash PoW scheme useful only for testing purposes.
func (*Entrustash) APIs ¶
func (entrustash *Entrustash) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs. Currently that is empty.
func (*Entrustash) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*Entrustash) Finalize ¶
func (entrustash *Entrustash) 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 (*Entrustash) Hashrate ¶
func (entrustash *Entrustash) Hashrate() float64
Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute.
func (*Entrustash) Prepare ¶
func (entrustash *Entrustash) Prepare(chain consensus.ChainReader, header *types.Header) error
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the entrustash protocol. The changes are done inline.
func (*Entrustash) Seal ¶
func (entrustash *Entrustash) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
Seal implements consensus.Engine, attempting to find a nonce that satisfies the block's difficulty requirements.
func (*Entrustash) SetThreads ¶
func (entrustash *Entrustash) SetThreads(threads int)
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 (*Entrustash) Threads ¶
func (entrustash *Entrustash) Threads() int
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*Entrustash) VerifyHeader ¶
func (entrustash *Entrustash) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Trustmachine entrustash engine.
func (*Entrustash) VerifyHeaders ¶
func (entrustash *Entrustash) 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 (*Entrustash) VerifySeal ¶
func (entrustash *Entrustash) VerifySeal(chain consensus.ChainReader, header *types.Header) error
VerifySeal implements consensus.Engine, checking whether the given block satisfies the PoW difficulty requirements.
func (*Entrustash) VerifyUncles ¶
func (entrustash *Entrustash) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Trustmachine entrustash engine.