Documentation ¶
Index ¶
- Variables
- func CalcDifficulty(chain consensus.ChainReader, config *params.ChainConfig, time uint64, ...) *big.Int
- type API
- type Config
- type EthPoc
- func (ethPoc *EthPoc) APIs(chain consensus.ChainReader) []rpc.API
- func (ethPoc *EthPoc) Author(header *types.Header) (common.Address, error)
- func (ethPoc *EthPoc) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (ethPoc *EthPoc) Close() error
- func (ethPoc *EthPoc) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...)
- func (ethPoc *EthPoc) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (ethPoc *EthPoc) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (ethPoc *EthPoc) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (ethPoc *EthPoc) SealHash(header *types.Header) (hash common.Hash)
- func (ethPoc *EthPoc) SetBlockChain(blockChain *core.BlockChain)
- func (ethPoc *EthPoc) SetThreads(threads int)
- func (ethPoc *EthPoc) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (ethPoc *EthPoc) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (ethPoc *EthPoc) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (ethPoc *EthPoc) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Mode
Constants ¶
This section is empty.
Variables ¶
var ( FrontierBlockReward = big.NewInt(5e+18) // Block reward in wei for successfully mining a block ByzantiumBlockReward = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium ConstantinopleBlockReward = big.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Constantinople INITIAL_BASE_TARGET uint64 = 18325193796 MAX_BASE_TARGET uint64 = 18325193796 ADJUST_BLOCK_NUMBER uint64 = 2700 BLOCK_INTERVAL uint64 = 60 * 3 HASH_SIZE = 32 HASHES_PER_SCOOP = 2 SCOOP_SIZE = HASHES_PER_SCOOP * HASH_SIZE SCOOPS_PER_PLOT = 4096 // original 1MB/plot = 16384 PLOT_SIZE = SCOOPS_PER_PLOT * SCOOP_SIZE HASH_CAP = 4096 YEAR_TIME uint64 = 60 * 60 * 24 * 365 EACH_NUMBER_OF_4YEAR = 4 * YEAR_TIME / BLOCK_INTERVAL )
EthPoc proof-of-work protocol constants.
Functions ¶
func CalcDifficulty ¶
func CalcDifficulty(chain consensus.ChainReader, config *params.ChainConfig, time uint64, 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.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API exposes ethash related methods for the RPC interface.
func (*API) GetHashrate ¶
GetHashrate 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 Config ¶
type Config struct {
PocMode Mode
}
Config are the configuration parameters of the ethPoc.
type EthPoc ¶
type EthPoc struct {
// contains filtered or unexported fields
}
EthPoc is a consensus engine based on proof-of-Capacity implementing the ethpoc algorithm.
func New ¶
func New(chainConfig *params.ChainConfig, am *accounts.Manager, config Config, notify []string, noverify bool) *EthPoc
New creates a full sized ethPoc 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 ethPoc 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 ethPoc 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() *EthPoc
NewFaker creates a ethPoc 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() *EthPoc
NewFullFaker creates an ethPoc consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func NewTester ¶
NewTester creates a small sized ethPoc PoW scheme useful only for testing purposes.
func (*EthPoc) APIs ¶
func (ethPoc *EthPoc) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*EthPoc) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*EthPoc) CalcDifficulty ¶
func (ethPoc *EthPoc) CalcDifficulty(chain consensus.ChainReader, time uint64, 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 (*EthPoc) Finalize ¶
func (ethPoc *EthPoc) Finalize(chain consensus.ChainReader, 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 and assembling the block.
func (*EthPoc) FinalizeAndAssemble ¶
func (ethPoc *EthPoc) FinalizeAndAssemble(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 (*EthPoc) Prepare ¶
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the EthPoc protocol. The changes are done inline.
func (*EthPoc) Seal ¶
func (ethPoc *EthPoc) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal implements consensus.Engine, attempting to find a nonce that satisfies the block's difficulty requirements.
func (*EthPoc) SetBlockChain ¶
func (ethPoc *EthPoc) SetBlockChain(blockChain *core.BlockChain)
func (*EthPoc) SetThreads ¶
func (*EthPoc) VerifyHeader ¶
func (ethPoc *EthPoc) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum EthPoc engine.
func (*EthPoc) VerifyHeaders ¶
func (ethPoc *EthPoc) 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 (*EthPoc) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the given block satisfies the PoW difficulty requirements.
func (*EthPoc) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the stock Ethereum EthPoc engine.