Documentation
¶
Overview ¶
Package rpow implements the random-proof-of-work consensus engine.
Index ¶
- Variables
- func SeedHash(block uint64) []byte
- type Config
- type Mode
- type Rpow
- func New(config Config) *Rpow
- func NewFakeDelayer(delay time.Duration) *Rpow
- func NewFakeFailer(fail uint64) *Rpow
- func NewFaker() *Rpow
- func NewFakerUsechain(db ethdb.Database) *Rpow
- func NewFullFaker() *Rpow
- func NewFullFakerUse(db ethdb.Database) *Rpow
- func NewTester() *Rpow
- func NewTesterUse(db ethdb.Database) *Rpow
- func (rpow *Rpow) APIs(chain consensus.ChainReader) []rpc.API
- func (rpow *Rpow) Author(header *types.Header) (common.Address, error)
- func (rpow *Rpow) CalcDifficulty(chain consensus.ChainReader, time uint64, header *types.Header, ...) *big.Int
- func (rpow *Rpow) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (rpow *Rpow) Prepare(chain consensus.ChainReader, header *types.Header, state *state.StateDB) error
- func (rpow *Rpow) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (rpow *Rpow) SetThreads(threads int)
- func (rpow *Rpow) Threads() int
- func (rpow *Rpow) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool, ...) error
- func (rpow *Rpow) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool, ...) (chan<- struct{}, <-chan error)
- func (rpow *Rpow) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (rpow *Rpow) VerifyUncles(chain consensus.ChainReader, block *types.Block, state *state.StateDB) error
Constants ¶
This section is empty.
Variables ¶
var (
CommonDifficulty = big.NewInt(1)
)
Genesis difficulty
var ( // Block reward in hui for successfully mining a block upward from Sapphir SapphireBlockReward *big.Int = big.NewInt(0).Mul(big.NewInt(1e+18), big.NewInt(15)) )
random-proof-of-work protocol constants.
Functions ¶
Types ¶
type Config ¶
type Config struct {
RpowMode Mode
}
Config are the configuration parameters of the rpow.
type Mode ¶
type Mode uint
Mode defines the type and amount of PoW verification a rpow engine makes.
type Rpow ¶
type Rpow struct {
// contains filtered or unexported fields
}
Rpow is a consensus engine based on proot-of-work implementing the rpow algorithm.
func NewFakeDelayer ¶
NewFakeDelayer creates a rpow 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 Ethereum consensus rules.
func NewFakeFailer ¶
NewFakeFailer creates a rpow 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 Ethereum consensus rules.
func NewFaker ¶
func NewFaker() *Rpow
NewFaker creates a rpow consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Ethereum consensus rules.
func NewFakerUsechain ¶
NewFakerUsechain creates a rpow consensus engine with a fake PoW scheme that accepts all blocks' seal as valid, though they still have to conform to the Ethereum consensus rules.
func NewFullFaker ¶
func NewFullFaker() *Rpow
NewFullFaker creates a rpow consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewFullFakerUse ¶
NewFullFakerUse creates a rpow consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewTester ¶
func NewTester() *Rpow
NewTester creates a small sized rpow scheme useful only for testing purposes.
func NewTesterUse ¶
func (*Rpow) APIs ¶
func (rpow *Rpow) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs. Currently that is empty.
func (*Rpow) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the rpow verified author of the block.
func (*Rpow) CalcDifficulty ¶
func (rpow *Rpow) CalcDifficulty(chain consensus.ChainReader, time uint64, header *types.Header, 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 (*Rpow) Finalize ¶
func (rpow *Rpow) 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 (*Rpow) Prepare ¶
func (rpow *Rpow) Prepare(chain consensus.ChainReader, header *types.Header, state *state.StateDB) error
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the pow protocol. The changes are done inline.
func (*Rpow) Seal ¶
func (rpow *Rpow) 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 (*Rpow) 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 (*Rpow) Threads ¶
Threads returns the number of mining threads currently enabled. This doesn't necessarily mean that mining is running!
func (*Rpow) VerifyHeader ¶
func (rpow *Rpow) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool, state *state.StateDB) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Usechain rpow engine.
func (*Rpow) VerifyHeaders ¶
func (rpow *Rpow) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool, state *state.StateDB) (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 (*Rpow) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the given block satisfies the Rpow difficulty requirements.
func (*Rpow) VerifyUncles ¶
func (rpow *Rpow) VerifyUncles(chain consensus.ChainReader, block *types.Block, state *state.StateDB) error
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Usechain rpow engine.