cbft

package
v1.8.17-0...-0f1be05 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package bft implements the BFT consensus engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAmount

func GetAmount(number *big.Int) *big.Int

func IsSignedBySelf

func IsSignedBySelf(sealHash common.Hash, signature []byte) bool

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

func (api *API) GetProducer(number *rpc.BlockNumber) (common.Address, error)

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

func NewBlockExt(block *types.Block, blockNum uint64) *BlockExt

New creates a BlockExt object

func NewEmptyExt

func NewEmptyExt(blockNum uint64) *BlockExt

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

func (cbft *Cbft) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.

func (*Cbft) Close

func (cbft *Cbft) Close() error

Close implements consensus.Engine. It's a noop for cbft as there is are no background threads.

func (*Cbft) ConsensusNodes

func (cbft *Cbft) ConsensusNodes(parentNumber *big.Int, parentHash common.Hash, blockNumber *big.Int) []discover.NodeID

func (*Cbft) CurrentNodes

func (cbft *Cbft) CurrentNodes(parentNumber *big.Int, parentHash common.Hash, blockNumber *big.Int) []*discover.Node

func (*Cbft) Election

func (cbft *Cbft) Election(state *state.StateDB, parentHash common.Hash, blockNumber *big.Int) ([]*discover.Node, error)

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 *Cbft) FindTransaction(txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64)

func (*Cbft) GetBlock

func (cbft *Cbft) GetBlock(hash common.Hash, number uint64) *types.Block

GetBlock returns the block in blockExtMap.

func (*Cbft) GetBody

func (cbft *Cbft) GetBody(blockNumber uint64) *types.Body

func (*Cbft) GetHeader

func (cbft *Cbft) GetHeader(blockHash common.Hash, blockNumber uint64) *types.Header

func (*Cbft) GetNewStateDB

func (cbft *Cbft) GetNewStateDB(root common.Hash, blockNumber *big.Int, blockHash common.Hash) (*state.StateDB, error)

func (*Cbft) GetOwnNodeID

func (cbft *Cbft) GetOwnNodeID() discover.NodeID

func (*Cbft) GetWitness

func (cbft *Cbft) GetWitness(state *state.StateDB, flag int, blockNumber *big.Int) ([]*discover.Node, error)

func (*Cbft) HighestConfirmedBlock

func (cbft *Cbft) HighestConfirmedBlock() *types.Block

HighestConfirmedBlock returns the cbft.highestConfirmed.block.

func (*Cbft) HighestLogicalBlock

func (cbft *Cbft) HighestLogicalBlock() *types.Block

HighestLogicalBlock returns the cbft.highestLogical.block.

func (*Cbft) IncreaseRewardPool

func (cbft *Cbft) IncreaseRewardPool(state *state.StateDB, number *big.Int)

func (*Cbft) IsCurrentNode

func (cbft *Cbft) IsCurrentNode(parentNumber *big.Int, parentHash common.Hash, blockNumber *big.Int) bool

func (*Cbft) Notify

func (cbft *Cbft) Notify(state vm.StateDB, blockNumber *big.Int) error

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

func (cbft *Cbft) OnNewBlock(chain consensus.ChainReader, rcvBlock *types.Block) error

OnNewBlock is called by protocol handler when it received a new block by P2P.

func (*Cbft) OnPong

func (cbft *Cbft) OnPong(nodeID discover.NodeID, netLatency int64) error

OnPong is called by protocol handler when it received a new Pong message by P2P.

func (*Cbft) Prepare

func (cbft *Cbft) Prepare(chain consensus.ChainReader, header *types.Header) error

Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.

func (*Cbft) RemovePeer

func (cbft *Cbft) RemovePeer(nodeID discover.NodeID)

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) SealHash

func (b *Cbft) SealHash(header *types.Header) common.Hash

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

func (*Cbft) SetNodeCache

func (cbft *Cbft) SetNodeCache(state *state.StateDB, parentNumber, currentNumber *big.Int, parentHash, currentHash common.Hash) error

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 *Cbft) ShouldSeal(parentNumber *big.Int, parentHash common.Hash, commitNumber *big.Int) bool

func (*Cbft) StoreHash

func (cbft *Cbft) StoreHash(state *state.StateDB, blockNumber *big.Int, blockHash common.Hash)

func (*Cbft) Submit2Cache

func (cbft *Cbft) Submit2Cache(state *state.StateDB, currBlocknumber *big.Int, blockInterval *big.Int, currBlockhash common.Hash)

func (*Cbft) Switch

func (cbft *Cbft) Switch(state *state.StateDB, blockNumber *big.Int) bool

func (*Cbft) VerifyHeader

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

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

func (cbft *Cbft) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*Cbft) VerifyUncles

func (cbft *Cbft) 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 FlowControl

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

FlowControl is a rectifier for sequential blocks

func NewFlowControl

func NewFlowControl() *FlowControl

Jump to

Keyboard shortcuts

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