Documentation ¶
Overview ¶
Package v1 implements the proof-of-authority consensus engine.
Index ¶
- func Ecrecover(header *types.Header, sigcache *lru.ARCCache) (common.Address, error)
- func SealHash(header *types.Header) (hash common.Hash)
- type API
- type Consortium
- func (c *Consortium) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (c *Consortium) Author(header *types.Header) (common.Address, error)
- func (c *Consortium) Authorize(signer common.Address, signFn consortiumCommon.SignerFn, ...)
- func (c *Consortium) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (c *Consortium) Close() error
- func (c *Consortium) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) error
- func (c *Consortium) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, []*types.Receipt, error)
- func (c *Consortium) GetSnapshot(chain consensus.ChainHeaderReader, number uint64, parents []*types.Header) *consortiumCommon.BaseSnapshot
- func (c *Consortium) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (c *Consortium) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (c *Consortium) SealHash(header *types.Header) common.Hash
- func (c *Consortium) SetGetFenixValidators(fn func() ([]common.Address, error))
- func (c *Consortium) SetGetSCValidatorsFn(fn func() ([]common.Address, error))
- func (c *Consortium) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
- func (c *Consortium) VerifyHeaderAndParents(chain consensus.ChainHeaderReader, header *types.Header, ...) error
- func (c *Consortium) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (c *Consortium) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error
- func (c *Consortium) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to allow controlling the signer and voting mechanisms of the proof-of-authority scheme.
func (*API) GetAncientValue ¶
func (*API) GetSigners ¶
GetSigners retrieves the list of authorized signers at the specified block.
type Consortium ¶
type Consortium struct {
// contains filtered or unexported fields
}
Consortium is the proof-of-authority consensus engine proposed to support the Ethereum testnet following the Ropsten attacks.
func New ¶
func New(chainConfig *params.ChainConfig, db ethdb.Database, ethAPI *ethapi.PublicBlockChainAPI) *Consortium
New creates a Consortium proof-of-authority consensus engine with the initial signers set to the ones provided by the user.
func (*Consortium) APIs ¶
func (c *Consortium) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API.
func (*Consortium) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*Consortium) Authorize ¶
func (c *Consortium) Authorize(signer common.Address, signFn consortiumCommon.SignerFn, signTxFn consortiumCommon.SignerTxFn)
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*Consortium) CalcDifficulty ¶
func (c *Consortium) 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.
func (*Consortium) Close ¶
func (c *Consortium) Close() error
Close implements consensus.Engine. It's a noop for consortium as there are no background threads.
func (*Consortium) Finalize ¶
func (c *Consortium) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs *[]*types.Transaction, uncles []*types.Header, receipts *[]*types.Receipt, systemTxs *[]*types.Transaction, internalTxs *[]*types.InternalTransaction, usedGas *uint64) error
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given.
func (*Consortium) FinalizeAndAssemble ¶
func (c *Consortium) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, []*types.Receipt, error)
FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*Consortium) GetSnapshot ¶
func (c *Consortium) GetSnapshot(chain consensus.ChainHeaderReader, number uint64, parents []*types.Header) *consortiumCommon.BaseSnapshot
func (*Consortium) Prepare ¶
func (c *Consortium) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Consortium) Seal ¶
func (c *Consortium) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.
func (*Consortium) SealHash ¶
func (c *Consortium) SealHash(header *types.Header) common.Hash
SealHash returns the hash of a block prior to it being sealed.
func (*Consortium) SetGetFenixValidators ¶
func (c *Consortium) SetGetFenixValidators(fn func() ([]common.Address, error))
SetGetFenixValidators sets the function to get the validator list from Ronin Validator contract of Fenix hardfork
func (*Consortium) SetGetSCValidatorsFn ¶
func (c *Consortium) SetGetSCValidatorsFn(fn func() ([]common.Address, error))
SetGetSCValidatorsFn sets the function to get a list of validators from smart contracts
func (*Consortium) VerifyHeader ¶
func (c *Consortium) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules.
func (*Consortium) VerifyHeaderAndParents ¶
func (c *Consortium) VerifyHeaderAndParents(chain consensus.ChainHeaderReader, header *types.Header, parents []*types.Header) error
VerifyHeaderAndParents checks whether a header conforms to the consensus rules.The caller may optionally pass in a batch of parents (ascending order) to avoid looking those up from the database. This is useful for concurrently verifying a batch of new headers.
func (*Consortium) VerifyHeaders ¶
func (c *Consortium) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).
func (*Consortium) VerifySeal ¶
func (c *Consortium) VerifySeal(chain consensus.ChainHeaderReader, header *types.Header) error
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Consortium) VerifyUncles ¶
func (c *Consortium) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.
type Snapshot ¶
type Snapshot struct { Number uint64 `json:"number"` // Block number where the snapshot was created Hash common.Hash `json:"hash"` // Block hash where the snapshot was created SignerSet map[common.Address]struct{} `json:"signerSet"` // Set of authorized signers at this moment SignerList []common.Address `json:"signerList"` // List of authorized signers at this moment Recents map[uint64]common.Address `json:"recents"` // Set of recent signers for spam protections // contains filtered or unexported fields }
Snapshot is the state of the authorization voting at a given point in time.