Documentation ¶
Overview ¶
Package ethash implements the ethash proof-of-work consensus engine.
Index ¶
- Constants
- Variables
- func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int
- type Config
- type Elephanthash
- func (elephanthash *Elephanthash) APIs(chain consensus.ChainReaderCtt) []rpc.API
- func (elephanthash *Elephanthash) Author(header *types.Header) (common.Address, error)
- func (elephanthash *Elephanthash) CalcDifficulty(chain consensus.ChainReaderCtt, time uint64, parent *types.Header) *big.Int
- func (elephanthash *Elephanthash) Finalize(chain consensus.ChainReaderCtt, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (elephanthash *Elephanthash) Prepare(chain consensus.ChainReaderCtt, header *types.Header) error
- func (elephanthash *Elephanthash) Seal(chain consensus.ChainReaderCtt, block *types.Block, stop <-chan struct{}) (*types.Block, []*types.HBFTStageCompleted, error)
- func (elephanthash *Elephanthash) VerifyBFT(chain consensus.ChainReaderCtt, block *types.Block) error
- func (elephanthash *Elephanthash) VerifyHeader(chain consensus.ChainReaderCtt, header *types.Header) error
- func (elephanthash *Elephanthash) VerifyHeaders(chain consensus.ChainReaderCtt, headers []*types.Header) (chan<- struct{}, <-chan error)
- type Mode
- type NodeHbftServer
Constants ¶
const ( Idle uint = iota // Node is created successfully, but the consensus process is not started yet. PreConfirm // The `preConfirmMsg` is processed successfully. The node is ready to head to the Confirm stage. Confirm // The `confirmMsg` is processed successfully. The node is ready to head to the next block processing. )
Stages copied from hbft_imp.go
Variables ¶
var ErrInvalidDumpMagic = errors.New("invalid dump magic")
var (
FrontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
)
Ethash proof-of-work protocol constants.
Functions ¶
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.
Types ¶
type Elephanthash ¶
type Elephanthash struct {
// contains filtered or unexported fields
}
Ethash is a consensus engine based on proot-of-work implementing the ethash algorithm.
func New ¶
func New(config Config, pbftNode *nodeHbft.Node) *Elephanthash
New creates a full sized ethash PoW scheme.
func NewTester ¶
func NewTester() *Elephanthash
NewTester creates a small sized ethash PoW scheme useful only for testing purposes.
func (*Elephanthash) APIs ¶
func (elephanthash *Elephanthash) APIs(chain consensus.ChainReaderCtt) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs. Currently that is empty.
func (*Elephanthash) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-work verified author of the block.
func (*Elephanthash) CalcDifficulty ¶
func (elephanthash *Elephanthash) CalcDifficulty(chain consensus.ChainReaderCtt, 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 (*Elephanthash) Finalize ¶
func (elephanthash *Elephanthash) Finalize(chain consensus.ChainReaderCtt, header *types.Header, state *state.StateDB, txs []*types.Transaction, inputTxs []*types.ShardingTxBatch, uncles []*types.Header, receipts []*types.Receipt, eBase *common.Address) (*types.Block, error)
Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.
func (*Elephanthash) Prepare ¶
func (elephanthash *Elephanthash) Prepare(chain consensus.ChainReaderCtt, header *types.Header) error
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the ethash protocol. The changes are done inline.
func (*Elephanthash) Seal ¶
func (elephanthash *Elephanthash) Seal(chain consensus.ChainReaderCtt, block *types.Block, stop <-chan struct{}) (*types.Block, []*types.HBFTStageCompleted, error)
Seal implements consensus.Engine, attempting to find a nonce that satisfies the block's difficulty requirements.
func (*Elephanthash) VerifyBFT ¶
func (elephanthash *Elephanthash) VerifyBFT(chain consensus.ChainReaderCtt, block *types.Block) error
VerifyBFT verifies that the given block's BFT records conform to the consensus rules of the engine.
func (*Elephanthash) VerifyHeader ¶
func (elephanthash *Elephanthash) VerifyHeader(chain consensus.ChainReaderCtt, header *types.Header) error
VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum ethash engine.
func (*Elephanthash) VerifyHeaders ¶
func (elephanthash *Elephanthash) VerifyHeaders(chain consensus.ChainReaderCtt, 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.