backend

package
v0.0.0-...-aecdb05 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2020 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrNoBroadcaster is return when trying to access backend.Broadcaster without SetBroadcaster first
	ErrNoBroadcaster = errors.New("no broadcaster is set")
)

Functions

func New

func New(config *tendermint.Config, privateKey *ecdsa.PrivateKey, opts ...Option) consensus.Tendermint

New creates an backend for Istanbul core engine. The p2p communication, i.e, broadcaster is set separately by calling backend.SetBroadcaster

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

----------------------------------------------------------------------------

func (*Backend) APIs

func (sb *Backend) APIs(chain consensus.ChainReader) []rpc.API

APIs will expose some RPC API methods

func (*Backend) Address

func (sb *Backend) Address() common.Address

Address implements tendermint.Backend.Address

func (*Backend) Author

func (sb *Backend) Author(header *types.Header) (common.Address, error)

Author retrieves the NeuralChain address of the account that minted the given block, which may be different from the header's coinbase if a consensus engine is based on signatures.

func (*Backend) Broadcast

func (sb *Backend) Broadcast(valSet tendermint.ValidatorSet, blockNumber *big.Int, round int64, msgType uint64, payload []byte) error

Broadcast implements tendermint.Backend.Broadcast It sends message to its validator by calling gossiping, and send message to itself by eventMux

func (*Backend) CalcDifficulty

func (sb *Backend) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int

CalcDifficulty tempo return default difficulty

func (*Backend) Cancel

func (sb *Backend) Cancel(block *types.Block)

func (*Backend) Close

func (sb *Backend) Close() error

Close terminates any background threads maintained by the consensus engine.

func (*Backend) Commit

func (sb *Backend) Commit(block *types.Block)

Commit implement tendermint.Backend.Commit()

func (*Backend) CurrentHeadBlock

func (sb *Backend) CurrentHeadBlock() *types.Block

func (*Backend) EventMux

func (sb *Backend) EventMux() *event.TypeMux

EventMux implements tendermint.Backend.EventMux

func (*Backend) Finalize

func (sb *Backend) Finalize(chain consensus.FullChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header) error

Finalize runs any post-transaction state modifications (e.g. block rewards)

Note, the block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).

func (*Backend) FinalizeAndAssemble

func (sb *Backend) FinalizeAndAssemble(chain consensus.FullChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

FinalizeAndAssemble runs any post-transaction state modifications (e.g. block rewards) and assembles the final block.

Note, the block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).

func (*Backend) FindExistingPeers

func (sb *Backend) FindExistingPeers(valSet tendermint.ValidatorSet) map[common.Address]consensus.Peer

FindExistingPeers check validator peers exist or not by address

func (*Backend) Gossip

func (sb *Backend) Gossip(valSet tendermint.ValidatorSet, blockNumber *big.Int, round int64, msgType uint64, payload []byte) error

Gossip implements tendermint.Backend.Gossip It sends message to its validators only, not itself. The validators must be able to connected through Peer. It will return backend.ErrNoBroadcaster if no broadcaster is set for backend

func (*Backend) HandleMsg

func (sb *Backend) HandleMsg(addr common.Address, msg p2p.Msg) (bool, error)

HandleMsg implements consensus.Handler.HandleMsg return false if the message cannot be handle by Tendermint Backend

func (*Backend) HandleNewChainHead

func (sb *Backend) HandleNewChainHead(blockNumber *big.Int) error

HandleNewChainHead implements consensus.Handler.HandleNewChainHead

func (*Backend) Multicast

func (sb *Backend) Multicast(targets map[common.Address]bool, payload []byte) error

Multicast implements tendermint.Backend.Multicast Send msgs to peers in a set of address return err if not found peer with address or sending failed

func (*Backend) Prepare

func (sb *Backend) Prepare(chain consensus.FullChainReader, header *types.Header) error

Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline.

func (*Backend) Seal

func (sb *Backend) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) (err error)

Seal generates a new block for the given input block with the local miner's seal place on top.

func (*Backend) SealHash

func (sb *Backend) SealHash(header *types.Header) (hash common.Hash)

SealHash returns the hash of a block prior to it being sealed.

func (*Backend) SetBroadcaster

func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)

SetBroadcaster implements consensus.Handler.SetBroadcaster

func (*Backend) Sign

func (sb *Backend) Sign(data []byte) ([]byte, error)

Sign implements tendermint.Backend.Sign

func (*Backend) Start

func (sb *Backend) Start(chain consensus.FullChainReader, currentBlock func() *types.Block, verifyAndSubmitBlock func(*types.Block) error) error

Start implements consensus.Tendermint.Start

func (*Backend) Stop

func (sb *Backend) Stop() error

Stop implements consensus.Tendermint.Stop

func (*Backend) Validators

func (sb *Backend) Validators(blockNumber *big.Int) tendermint.ValidatorSet

Validators return validator set for a block number

func (*Backend) ValidatorsByChainReader

func (sb *Backend) ValidatorsByChainReader(blockNumber *big.Int, chain consensus.ChainReader) tendermint.ValidatorSet

ValidatorsByChainReader returns val-set from snapshot

func (*Backend) VerifyHeader

func (sb *Backend) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error

VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifying the seal may be done optionally here, or explicitly via the VerifySeal method.

func (*Backend) VerifyHeaders

func (sb *Backend) 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 (the order is that of the input slice).

func (*Backend) VerifyProposalBlock

func (sb *Backend) VerifyProposalBlock(block *types.Block) error

VerifyProposalBlock verify post-processor state of proposal block (txs, Root, receipt). If success, the result will be send to the pending tasks of miner

func (*Backend) VerifyProposalHeader

func (sb *Backend) VerifyProposalHeader(header *types.Header) error

VerifyProposalHeader will call be.verifyHeader for checking

func (*Backend) VerifySeal

func (sb *Backend) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.

func (*Backend) VerifyUncles

func (sb *Backend) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles verifies that the given block's uncles conform to the consensus rules of a given engine.

type Option

type Option func(b *Backend) error

Option return an optional function for backend's initial behaviour

type TendermintAPI

type TendermintAPI struct {
	// contains filtered or unexported fields
}

TendermintAPI is a user facing RPC API to dump tendermint state

func (*TendermintAPI) GetValidators

func (api *TendermintAPI) GetValidators(number *uint64) []common.Address

GetValidators returns the list of validators by block's number

type ValidatorSetInfo

type ValidatorSetInfo interface {
	GetValSet(chainReader consensus.ChainReader, blockNumber *big.Int) (tendermint.ValidatorSet, error)
}

ValidatorSetInfo keep tracks of validator set in associate with blockNumber

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL