Documentation ¶
Index ¶
- func CalcDifficulty(snap *Snapshot, signer common.Address) *big.Int
- func FindAncientHeader(header *types.Header, ite uint64, chain consensus.ChainHeaderReader, ...) *types.Header
- func ParliaRLP(header *types.Header, chainId *big.Int) []byte
- func ParseValidators(validatorsBytes []byte) ([]common.Address, error)
- func SealHash(header *types.Header, chainId *big.Int) (hash common.Hash)
- type API
- func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
- func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)
- func (api *API) GetValidators(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetValidatorsAtHash(hash common.Hash) ([]common.Address, error)
- type Parlia
- func (p *Parlia) APIs(chain consensus.ChainHeaderReader) []rpc.API
- func (p *Parlia) AllowLightProcess(chain consensus.ChainReader, currentHeader *types.Header) bool
- func (p *Parlia) Author(header *types.Header) (common.Address, error)
- func (p *Parlia) Authorize(val common.Address, signFn SignerFn, signTxFn SignerTxFn)
- func (p *Parlia) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
- func (p *Parlia) Close() error
- func (p *Parlia) Delay(chain consensus.ChainReader, header *types.Header) *time.Duration
- func (p *Parlia) EnoughDistance(chain consensus.ChainReader, header *types.Header) bool
- func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) error
- func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, ...) (*types.Block, []*types.Receipt, error)
- func (p *Parlia) IsLocalBlock(header *types.Header) bool
- func (p *Parlia) IsSystemContract(to *common.Address) bool
- func (p *Parlia) IsSystemTransaction(tx *types.Transaction, header *types.Header) (bool, error)
- func (p *Parlia) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error
- func (p *Parlia) Seal(chain consensus.ChainHeaderReader, block *types.Block, ...) error
- func (p *Parlia) SealHash(header *types.Header) common.Hash
- func (p *Parlia) SignRecently(chain consensus.ChainReader, parent *types.Header) (bool, error)
- func (p *Parlia) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
- func (p *Parlia) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (p *Parlia) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (p *Parlia) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type SignerFn
- type SignerTxFn
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcDifficulty ¶
CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty that a new block should have based on the previous blocks in the chain and the current signer.
func FindAncientHeader ¶
func ParliaRLP ¶
ParliaRLP returns the rlp bytes which needs to be signed for the parlia sealing. The RLP to sign consists of the entire header apart from the 65 byte signature contained at the end of the extra data.
Note, the method requires the extra data to be at least 65 bytes, otherwise it panics. This is done to avoid accidentally using both forms (signature present or not), which could be abused to produce different hashes for the same header.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to allow query snapshot and validators
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetSnapshotAtHash ¶
GetSnapshotAtHash retrieves the state snapshot at a given block.
func (*API) GetValidators ¶
GetValidators retrieves the list of validators at the specified block.
type Parlia ¶
type Parlia struct {
// contains filtered or unexported fields
}
Parlia is the consensus engine of BSC
func New ¶
func New( chainConfig *params.ChainConfig, db ethdb.Database, ethAPI *ethapi.PublicBlockChainAPI, genesisHash common.Hash, ) *Parlia
New creates a Parlia consensus engine.
func (*Parlia) APIs ¶
func (p *Parlia) APIs(chain consensus.ChainHeaderReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API to query snapshot.
func (*Parlia) AllowLightProcess ¶
func (*Parlia) Authorize ¶
func (p *Parlia) Authorize(val common.Address, signFn SignerFn, signTxFn SignerTxFn)
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*Parlia) CalcDifficulty ¶
func (p *Parlia) 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 based on the previous blocks in the chain and the current signer.
func (*Parlia) Close ¶
Close implements consensus.Engine. It's a noop for parlia as there are no background threads.
func (*Parlia) EnoughDistance ¶
func (*Parlia) Finalize ¶
func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs *[]*types.Transaction, uncles []*types.Header, receipts *[]*types.Receipt, systemTxs *[]*types.Transaction, usedGas *uint64) error
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given.
func (*Parlia) FinalizeAndAssemble ¶
func (p *Parlia) 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 (*Parlia) IsSystemTransaction ¶
func (*Parlia) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Parlia) Seal ¶
func (p *Parlia) 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 (*Parlia) SignRecently ¶
func (*Parlia) VerifyHeader ¶
func (p *Parlia) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error
VerifyHeader checks whether a header conforms to the consensus rules.
func (*Parlia) VerifyHeaders ¶
func (p *Parlia) 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 (*Parlia) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Parlia) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.
type SignerFn ¶
SignerFn is a signer callback function to request a header to be signed by a backing account.
type SignerTxFn ¶
type SignerTxFn func(accounts.Account, *types.Transaction, *big.Int) (*types.Transaction, error)
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 Validators map[common.Address]struct{} `json:"validators"` // Set of authorized validators at this moment Recents map[uint64]common.Address `json:"recents"` // Set of recent validators for spam protections RecentForkHashes map[uint64]string `json:"recent_fork_hashes"` // Set of recent forkHash // contains filtered or unexported fields }
Snapshot is the state of the validatorSet at a given point.