cbft

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package bft implements the BFT consensus engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContractNotFound = errors.New("contract not found")
)

Functions

func IsSignedBySelf

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

IsSignedBySelf returns if the block is signed by local.

func ReloadCBFTParams

func ReloadCBFTParams()

ReloadCBFTParams reload params

func SetBackend

func SetBackend(blockChain *core.BlockChain, txPool *core.TxPool)

SetBackend sets blockChain and txPool into cbft

func SetBlockChainCache

func SetBlockChainCache(blockChainCache *core.BlockChainCache)

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 {
	// 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

type CBFTProduceBlockCfg

type CBFTProduceBlockCfg struct {
	ProduceDuration int32 `json:"ProduceDuration"`
	BlockInterval   int32 `json:"BlockInterval"`
}

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

func (cbft *Cbft) CheckConsensusNode(nodeID discover.NodeID) (bool, error)

CheckConsensusNode check if the nodeID is a consensus node.

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() ([]discover.NodeID, error)

ConsensusNodes returns all consensus nodes.

func (*Cbft) Finalize

func (cbft *Cbft) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, receipts []*types.Receipt) (*types.Block, error)

Finalize implements consensus.Engine, no block rewards given, and returns the final block.

func (*Cbft) GetBlock

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

GetBlock returns the block in blockExtMap.

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

func (cbft *Cbft) IsConsensusNode() (bool, error)

IsConsensusNode check if local is a consensus node.

func (*Cbft) IsPrimaryNode

func (cbft *Cbft) IsPrimaryNode() bool

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

func (cbft *Cbft) Seal(chain consensus.ChainReader, block *types.Block, sealResultCh chan<- *types.Block, stopCh <-chan struct{}) (*types.Block, error)

to sign the block, and store the sign to header.Extra[32:], 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) 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() (bool, error)

ShouldSeal checks if it's local's turn to package new block at current time.

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.

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