Documentation
¶
Overview ¶
Package bft implements the BFT consensus engine.
Index ¶
- func GetAmount(number *big.Int) *big.Int
- func IsSignedBySelf(sealHash common.Hash, signature []byte) bool
- func SetBackend(blockChain *core.BlockChain, txPool *core.TxPool)
- func SetBlockChainCache(blockChainCache *core.BlockChainCache)
- func SetPposOption(blockChain *core.BlockChain)
- type API
- type BlockExt
- type Cbft
- func (cbft *Cbft) APIs(chain consensus.ChainReader) []rpc.API
- func (cbft *Cbft) Author(header *types.Header) (common.Address, error)
- func (cbft *Cbft) Close() error
- func (cbft *Cbft) ConsensusNodes(parentNumber *big.Int, parentHash common.Hash, blockNumber *big.Int) []discover.NodeID
- func (cbft *Cbft) CurrentNodes(parentNumber *big.Int, parentHash common.Hash, blockNumber *big.Int) []*discover.Node
- func (cbft *Cbft) Election(state *state.StateDB, parentHash common.Hash, blockNumber *big.Int) ([]*discover.Node, error)
- func (cbft *Cbft) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (cbft *Cbft) FindTransaction(txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64)
- func (cbft *Cbft) GetBlock(hash common.Hash, number uint64) *types.Block
- func (cbft *Cbft) GetBody(blockNumber uint64) *types.Body
- func (cbft *Cbft) GetHeader(blockHash common.Hash, blockNumber uint64) *types.Header
- func (cbft *Cbft) GetNewStateDB(root common.Hash, blockNumber *big.Int, blockHash common.Hash) (*state.StateDB, error)
- func (cbft *Cbft) GetOwnNodeID() discover.NodeID
- func (cbft *Cbft) GetWitness(state *state.StateDB, flag int, blockNumber *big.Int) ([]*discover.Node, error)
- func (cbft *Cbft) HighestConfirmedBlock() *types.Block
- func (cbft *Cbft) HighestLogicalBlock() *types.Block
- func (cbft *Cbft) IncreaseRewardPool(state *state.StateDB, number *big.Int)
- func (cbft *Cbft) IsCurrentNode(parentNumber *big.Int, parentHash common.Hash, blockNumber *big.Int) bool
- func (cbft *Cbft) Notify(state vm.StateDB, blockNumber *big.Int) error
- func (cbft *Cbft) OnBlockSignature(chain consensus.ChainReader, nodeID discover.NodeID, ...) error
- func (cbft *Cbft) OnBlockSynced()
- func (cbft *Cbft) OnNewBlock(chain consensus.ChainReader, rcvBlock *types.Block) error
- func (cbft *Cbft) OnPong(nodeID discover.NodeID, netLatency int64) error
- func (cbft *Cbft) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (cbft *Cbft) RemovePeer(nodeID discover.NodeID)
- func (cbft *Cbft) Seal(chain consensus.ChainReader, block *types.Block, ...) error
- func (b *Cbft) SealHash(header *types.Header) common.Hash
- func (cbft *Cbft) SetNodeCache(state *state.StateDB, parentNumber, currentNumber *big.Int, ...) error
- func (cbft *Cbft) SetPrivateKey(privateKey *ecdsa.PrivateKey)
- func (cbft *Cbft) ShouldSeal(parentNumber *big.Int, parentHash common.Hash, commitNumber *big.Int) bool
- func (cbft *Cbft) StoreHash(state *state.StateDB, blockNumber *big.Int, blockHash common.Hash)
- func (cbft *Cbft) Submit2Cache(state *state.StateDB, currBlocknumber *big.Int, blockInterval *big.Int, ...)
- func (cbft *Cbft) Switch(state *state.StateDB, blockNumber *big.Int) bool
- func (cbft *Cbft) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (cbft *Cbft) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (cbft *Cbft) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (cbft *Cbft) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type FlowControl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSignedBySelf ¶
IsSignedBySelf returns if the block is signed by local.
func SetBackend ¶
func SetBackend(blockChain *core.BlockChain, txPool *core.TxPool)
SetBackend sets blockChain and txPool into cbft
func SetBlockChainCache ¶
func SetBlockChainCache(blockChainCache *core.BlockChainCache)
func SetPposOption ¶
func SetPposOption(blockChain *core.BlockChain)
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func (*API) GetProducer ¶
Get the block address
type BlockExt ¶
type BlockExt struct { Number uint64 `json:"number"` Hash string `json:"hash"` Children []*BlockExt `json:"children"` // contains filtered or unexported fields }
BlockExt is an extension from Block
func NewBlockExt ¶
New creates a BlockExt object
func NewEmptyExt ¶
type Cbft ¶
type Cbft struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *params.CbftConfig, blockSignatureCh chan *cbfttypes.BlockSignature, cbftResultCh chan *cbfttypes.CbftResult, highestLogicalBlockCh chan *types.Block) *Cbft
New creates a concurrent BFT consensus engine
func (*Cbft) APIs ¶
func (cbft *Cbft) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.
func (*Cbft) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*Cbft) Close ¶
Close implements consensus.Engine. It's a noop for cbft as there is are no background threads.
func (*Cbft) ConsensusNodes ¶
func (*Cbft) CurrentNodes ¶
func (*Cbft) Finalize ¶
func (cbft *Cbft) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*Cbft) FindTransaction ¶
func (*Cbft) GetNewStateDB ¶
func (*Cbft) GetOwnNodeID ¶
func (*Cbft) GetWitness ¶
func (*Cbft) HighestConfirmedBlock ¶
HighestConfirmedBlock returns the cbft.highestConfirmed.block.
func (*Cbft) HighestLogicalBlock ¶
HighestLogicalBlock returns the cbft.highestLogical.block.
func (*Cbft) IncreaseRewardPool ¶
func (*Cbft) IsCurrentNode ¶
func (*Cbft) OnBlockSignature ¶
func (cbft *Cbft) OnBlockSignature(chain consensus.ChainReader, nodeID discover.NodeID, rcvSign *cbfttypes.BlockSignature) error
OnBlockSignature is called by by protocol handler when it received a new block signature by P2P.
func (*Cbft) OnBlockSynced ¶
func (cbft *Cbft) OnBlockSynced()
BlockSynchronisation reset the cbft env, such as cbft.highestLogical, cbft.highestConfirmed. This function is invoked after that local has synced new blocks from other node.
func (*Cbft) OnNewBlock ¶
OnNewBlock is called by protocol handler when it received a new block by P2P.
func (*Cbft) OnPong ¶
OnPong is called by protocol handler when it received a new Pong message by P2P.
func (*Cbft) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Cbft) RemovePeer ¶
RemovePeer remove the net latency info from netLatencyMap.
func (*Cbft) Seal ¶
func (cbft *Cbft) Seal(chain consensus.ChainReader, block *types.Block, sealResultCh chan<- *types.Block, stopCh <-chan struct{}) error
to sign the block, and store the sign to header.Extra[32:97], send the sign to chanel to broadcast to other consensus nodes
func (*Cbft) SetNodeCache ¶
func (*Cbft) SetPrivateKey ¶
func (cbft *Cbft) SetPrivateKey(privateKey *ecdsa.PrivateKey)
SetPrivateKey sets local's private key by the backend.go
func (*Cbft) ShouldSeal ¶
func (*Cbft) Submit2Cache ¶
func (*Cbft) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules.
func (*Cbft) VerifyHeaders ¶
func (cbft *Cbft) VerifyHeaders(chain consensus.ChainReader, 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 (*Cbft) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Cbft) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.
type FlowControl ¶
type FlowControl struct {
// contains filtered or unexported fields
}
FlowControl is a rectifier for sequential blocks
func NewFlowControl ¶
func NewFlowControl() *FlowControl