Documentation ¶
Index ¶
- Variables
- func New(config *tendermint.Config, privateKey *ecdsa.PrivateKey, opts ...Option) consensus.Tendermint
- type Backend
- func (sb *Backend) APIs(chain consensus.ChainReader) []rpc.API
- func (sb *Backend) Address() common.Address
- func (sb *Backend) Author(header *types.Header) (common.Address, error)
- func (sb *Backend) Broadcast(valSet tendermint.ValidatorSet, blockNumber *big.Int, round int64, ...) error
- func (sb *Backend) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (sb *Backend) Cancel(block *types.Block)
- func (sb *Backend) Close() error
- func (sb *Backend) Commit(block *types.Block)
- func (sb *Backend) CurrentHeadBlock() *types.Block
- func (sb *Backend) EventMux() *event.TypeMux
- func (sb *Backend) Finalize(chain consensus.FullChainReader, header *types.Header, state *state.StateDB, ...) error
- func (sb *Backend) FinalizeAndAssemble(chain consensus.FullChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (sb *Backend) FindExistingPeers(valSet tendermint.ValidatorSet) map[common.Address]consensus.Peer
- func (sb *Backend) Gossip(valSet tendermint.ValidatorSet, blockNumber *big.Int, round int64, ...) error
- func (sb *Backend) HandleMsg(addr common.Address, msg p2p.Msg) (bool, error)
- func (sb *Backend) HandleNewChainHead(blockNumber *big.Int) error
- func (sb *Backend) Multicast(targets map[common.Address]bool, payload []byte) error
- func (sb *Backend) Prepare(chain consensus.FullChainReader, header *types.Header) error
- func (sb *Backend) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) (err error)
- func (sb *Backend) SealHash(header *types.Header) (hash common.Hash)
- func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
- func (sb *Backend) Sign(data []byte) ([]byte, error)
- func (sb *Backend) Start(chain consensus.FullChainReader, currentBlock func() *types.Block, ...) error
- func (sb *Backend) Stop() error
- func (sb *Backend) Validators(blockNumber *big.Int) tendermint.ValidatorSet
- func (sb *Backend) ValidatorsByChainReader(blockNumber *big.Int, chain consensus.ChainReader) tendermint.ValidatorSet
- func (sb *Backend) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (sb *Backend) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (sb *Backend) VerifyProposalBlock(block *types.Block) error
- func (sb *Backend) VerifyProposalHeader(header *types.Header) error
- func (sb *Backend) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (sb *Backend) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type Option
- type TendermintAPI
- type ValidatorSetInfo
Constants ¶
This section is empty.
Variables ¶
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) Author ¶
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) CurrentHeadBlock ¶
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 ¶
HandleMsg implements consensus.Handler.HandleMsg return false if the message cannot be handle by Tendermint Backend
func (*Backend) HandleNewChainHead ¶
HandleNewChainHead implements consensus.Handler.HandleNewChainHead
func (*Backend) Multicast ¶
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 ¶
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) SetBroadcaster ¶
func (sb *Backend) SetBroadcaster(broadcaster consensus.Broadcaster)
SetBroadcaster implements consensus.Handler.SetBroadcaster
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) 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 ¶
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 ¶
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 ¶
VerifyProposalHeader will call be.verifyHeader for checking
func (*Backend) VerifySeal ¶
VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.
func (*Backend) VerifyUncles ¶
VerifyUncles verifies that the given block's uncles conform to the consensus rules of a given engine.
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