Documentation ¶
Index ¶
- func IsTTDReached(chain consensus.ChainHeaderReader, parentHash common.Hash, parentNumber uint64) (bool, error)
- func NewFaker() consensus.Engine
- type Beacon
- func (beacon *Beacon) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (beacon *Beacon) Author(header *types.Header) (common.Address, error)
- func (beacon *Beacon) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (beacon *Beacon) Close() error
- func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...)
- func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (beacon *Beacon) InnerEngine() consensus.Engine
- func (beacon *Beacon) IsPoSHeader(header *types.Header) bool
- func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (beacon *Beacon) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (beacon *Beacon) SealHash(header *types.Header) common.Hash
- func (beacon *Beacon) SetThreads(threads int)
- func (beacon *Beacon) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error
- func (beacon *Beacon) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (chan<- struct{}, <-chan error)
- func (beacon *Beacon) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTTDReached ¶
func IsTTDReached(chain consensus.ChainHeaderReader, parentHash common.Hash, parentNumber uint64) (bool, error)
IsTTDReached checks if the TotalTerminalDifficulty has been surpassed on the `parentHash` block. It depends on the parentHash already being stored in the database. If the parentHash is not stored in the database a UnknownAncestor error is returned.
Types ¶
type Beacon ¶
type Beacon struct {
// contains filtered or unexported fields
}
Beacon is a consensus engine that combines the eth1 consensus and proof-of-stake algorithm. There is a special flag inside to decide whether to use legacy consensus rules or new rules. The transition rule is described in the eth1/2 merge spec. github.com/ethereum/EIPs/blob/master/EIPS/eip-3675.md
The beacon here is a half-functional consensus engine with partial functions which is only used for necessary consensus checks. The legacy consensus engine can be any engine implements the consensus interface (except the beacon itself).
func (*Beacon) APIs ¶
func (beacon *Beacon) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*Beacon) Author ¶
Author implements consensus.Engine, returning the verified author of the block.
func (*Beacon) CalcDifficulty ¶
func (beacon *Beacon) CalcDifficulty(chain consensus.ChainHeaderReader, 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 (*Beacon) Finalize ¶
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body)
Finalize implements consensus.Engine and processes withdrawals on top.
func (*Beacon) FinalizeAndAssemble ¶
func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error)
FinalizeAndAssemble implements consensus.Engine, setting the final state and assembling the block.
func (*Beacon) InnerEngine ¶
InnerEngine returns the embedded eth1 consensus engine.
func (*Beacon) IsPoSHeader ¶
IsPoSHeader reports the header belongs to the PoS-stage with some special fields. This function is not suitable for a part of APIs like Prepare or CalcDifficulty because the header difficulty is not set yet.
func (*Beacon) Prepare ¶
Prepare implements consensus.Engine, initializing the difficulty field of a header to conform to the beacon protocol. The changes are done inline.
func (*Beacon) Seal ¶
func (beacon *Beacon) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal generates a new sealing request for the given input block and pushes the result into the given channel.
Note, the method returns immediately and will send the result async. More than one result may also be returned depending on the consensus algorithm.
func (*Beacon) SetThreads ¶
SetThreads updates the mining threads. Delegate the call to the eth1 engine if it's threaded.
func (*Beacon) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules of the stock Ethereum consensus engine.
func (*Beacon) VerifyHeaders ¶
func (beacon *Beacon) 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. VerifyHeaders expect the headers to be ordered and continuous.
func (*Beacon) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of the Ethereum consensus engine.