Documentation ¶
Index ¶
- func LastBlockFromLedgerOrPanic(ledger Ledger, logger Logger) *cb.Block
- func LastConfigBlockFromLedgerOrPanic(ledger Ledger, logger Logger) *cb.Block
- func PreviousConfigBlockFromLedgerOrPanic(ledger Ledger, logger Logger) *cb.Block
- func ProposalToBlock(proposal types.Proposal) (*cb.Block, error)
- func RemoteNodesFromConfigBlock(block *cb.Block, logger *flogging.FabricLogger, bccsp bccsp.BCCSP) (*nodeConfig, error)
- type AccessController
- type Assembler
- type BFTBlockDeliverer
- type BFTChain
- func (c *BFTChain) BlockToDecision(block *cb.Block) *types.Decision
- func (c *BFTChain) Configure(config *cb.Envelope, configSeq uint64) error
- func (c *BFTChain) Deliver(proposal types.Proposal, signatures []types.Signature) types.Reconfig
- func (c *BFTChain) Errored() <-chan struct{}
- func (c *BFTChain) GetLeaderID() uint64
- func (c *BFTChain) Halt()
- func (c *BFTChain) HandleMessage(sender uint64, m *smartbftprotos.Message)
- func (c *BFTChain) HandleRequest(sender uint64, req []byte)
- func (c *BFTChain) Order(env *cb.Envelope, configSeq uint64) error
- func (c *BFTChain) Start()
- func (c *BFTChain) StatusReport() (types2.ConsensusRelation, types2.Status)
- func (c *BFTChain) WaitReady() error
- type BFTDelivererFactory
- type BFTSynchronizer
- type BlockPuller
- type BlockPullerFactory
- type Bundle
- type ByteBufferTuple
- type ChainGetter
- type ConfigBlockValidator
- type ConfigTxValidator
- type ConfigUpdateProposer
- type ConfigValidator
- type Consenter
- func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *cb.Metadata) (consensus.Chain, error)
- func (c *Consenter) IsChannelMember(joinBlock *cb.Block) (bool, error)
- func (c *Consenter) ReceiverByChain(channelID string) MessageReceiver
- func (c *Consenter) TargetChannel(message proto.Message) string
- type ConsenterCertificate
- type ConsenterVerifier
- type CounterConverter
- type CreateChainCallback
- type Egress
- type EgressComm
- type EgressCommFactory
- type Filters
- type GaugeConverter
- type HistogramConverter
- type Ingress
- type Ledger
- type Logger
- type MessageReceiver
- type MetricProviderConverter
- type Metrics
- type NodeIdentitiesByID
- type PolicyManagerRetriever
- type RPC
- type ReceiverGetter
- type RequestInspector
- type RuntimeConfig
- type Sequencer
- type Signature
- type Signer
- type SignerSerializer
- type SyncBuffer
- type Synchronizer
- type SynchronizerFactory
- type Verifier
- func (v *Verifier) AuxiliaryData(msg []byte) []byte
- func (v *Verifier) RequestsFromProposal(proposal types.Proposal) []types.RequestInfo
- func (v *Verifier) VerificationSequence() uint64
- func (v *Verifier) VerifyConsenterSig(signature types.Signature, prop types.Proposal) ([]byte, error)
- func (v *Verifier) VerifyProposal(proposal types.Proposal) ([]types.RequestInfo, error)
- func (v *Verifier) VerifyRequest(rawRequest []byte) (types.RequestInfo, error)
- func (v *Verifier) VerifySignature(signature types.Signature) error
- type VerifierFactory
- type WALConfig
- type WarningLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LastBlockFromLedgerOrPanic ¶
LastBlockFromLedgerOrPanic returns the last block from the ledger
func LastConfigBlockFromLedgerOrPanic ¶
LastConfigBlockFromLedgerOrPanic returns the last config block from the ledger
func ProposalToBlock ¶
ProposalToBlock marshals the proposal the block
func RemoteNodesFromConfigBlock ¶
func RemoteNodesFromConfigBlock(block *cb.Block, logger *flogging.FabricLogger, bccsp bccsp.BCCSP) (*nodeConfig, error)
RemoteNodesFromConfigBlock unmarshals the node config from the block metadata
Types ¶
type AccessController ¶
type AccessController interface { // Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy Evaluate(signatureSet []*protoutil.SignedData) error }
AccessController is used to determine if a signature of a certain client is valid
type Assembler ¶
type Assembler struct { RuntimeConfig *atomic.Value Logger *flogging.FabricLogger VerificationSeq func() uint64 }
Assembler is the proposal assembler
type BFTBlockDeliverer ¶
type BFTChain ¶
type BFTChain struct { RuntimeConfig *atomic.Value Channel string Config types.Configuration Comm cluster.Communicator SignerSerializer signerSerializer PolicyManager policies.Manager Logger *flogging.FabricLogger WALDir string ClusterService *cluster.ClusterService Metrics *Metrics MetricsBFT *api.Metrics MetricsWalBFT *wal.Metrics // contains filtered or unexported fields }
BFTChain implements Chain interface to wire with BFT smart library
func NewChain ¶
func NewChain( cv ConfigValidator, selfID uint64, config types.Configuration, walDir string, clusterDialer *cluster.PredicateDialer, localConfigCluster localconfig.Cluster, comm cluster.Communicator, signerSerializer signerSerializer, policyManager policies.Manager, support consensus.ConsenterSupport, metrics *Metrics, metricsBFT *api.Metrics, metricsWalBFT *wal.Metrics, bccsp bccsp.BCCSP, egressCommFactory EgressCommFactory, synchronizerFactory SynchronizerFactory, ) (*BFTChain, error)
NewChain creates new BFT Smart chain
func (*BFTChain) BlockToDecision ¶
func (*BFTChain) Configure ¶
Configure accepts a message which reconfigures the channel and will trigger an update to the configSeq if committed. The configuration must have been triggered by a ConfigUpdate message. If the config sequence advances, it is the responsibility of the consenter to recompute the resulting config, discarding the message if the reconfiguration is no longer valid. The consenter may return an error, indicating the message was not accepted
func (*BFTChain) Errored ¶
func (c *BFTChain) Errored() <-chan struct{}
Errored returns a channel which will close when an error has occurred. This is especially useful for the Deliver client, who must terminate waiting clients when the consenter is not up to date.
func (*BFTChain) GetLeaderID ¶
func (*BFTChain) Halt ¶
func (c *BFTChain) Halt()
Halt frees the resources which were allocated for this Chain.
func (*BFTChain) HandleMessage ¶
func (c *BFTChain) HandleMessage(sender uint64, m *smartbftprotos.Message)
HandleMessage handles the message from the sender
func (*BFTChain) HandleRequest ¶
HandleRequest handles the request from the sender
func (*BFTChain) Order ¶
Order accepts a message which has been processed at a given configSeq. If the configSeq advances, it is the responsibility of the consenter to revalidate and potentially discard the message The consenter may return an error, indicating the message was not accepted
func (*BFTChain) Start ¶
func (c *BFTChain) Start()
Start should allocate whatever resources are needed for staying up to date with the chain. Typically, this involves creating a thread which reads from the ordering source, passes those messages to a block cutter, and writes the resulting blocks to the ledger.
func (*BFTChain) StatusReport ¶
func (c *BFTChain) StatusReport() (types2.ConsensusRelation, types2.Status)
StatusReport returns the ConsensusRelation & Status
func (*BFTChain) WaitReady ¶
WaitReady blocks waiting for consenter to be ready for accepting new messages. This is useful when consenter needs to temporarily block ingress messages so that in-flight messages can be consumed. It could return error if consenter is in erroneous states. If this blocking behavior is not desired, consenter could simply return nil.
type BFTDelivererFactory ¶
type BFTDelivererFactory interface { CreateBFTDeliverer( channelID string, blockHandler blocksprovider.BlockHandler, ledger blocksprovider.LedgerInfo, updatableBlockVerifier blocksprovider.UpdatableBlockVerifier, dialer blocksprovider.Dialer, orderersSourceFactory blocksprovider.OrdererConnectionSourceFactory, cryptoProvider bccsp.BCCSP, doneC chan struct{}, signer identity.SignerSerializer, deliverStreamer blocksprovider.DeliverStreamer, censorshipDetectorFactory blocksprovider.CensorshipDetectorFactory, logger *flogging.FabricLogger, initialRetryInterval time.Duration, maxRetryInterval time.Duration, blockCensorshipTimeout time.Duration, maxRetryDuration time.Duration, maxRetryDurationExceededHandler blocksprovider.MaxRetryDurationExceededHandler, ) BFTBlockDeliverer }
type BFTSynchronizer ¶
type BFTSynchronizer struct { LatestConfig func() (types.Configuration, []uint64) BlockToDecision func(*common.Block) *types.Decision OnCommit func(*common.Block) types.Reconfig Support consensus.ConsenterSupport CryptoProvider bccsp.BCCSP ClusterDialer *cluster.PredicateDialer LocalConfigCluster localconfig.Cluster BlockPullerFactory BlockPullerFactory VerifierFactory VerifierFactory BFTDelivererFactory BFTDelivererFactory Logger *flogging.FabricLogger // contains filtered or unexported fields }
func (*BFTSynchronizer) Buffer ¶
func (s *BFTSynchronizer) Buffer() *SyncBuffer
Buffer return the internal SyncBuffer for testability.
func (*BFTSynchronizer) Sync ¶
func (s *BFTSynchronizer) Sync() types.SyncResponse
type BlockPuller ¶
type BlockPuller interface { PullBlock(seq uint64) *cb.Block HeightsByEndpoints() (map[string]uint64, string, error) Close() }
BlockPuller is used to pull blocks from other OSN
type BlockPullerFactory ¶
type BlockPullerFactory interface { // CreateBlockPuller creates a new block puller. CreateBlockPuller( support consensus.ConsenterSupport, baseDialer *cluster.PredicateDialer, clusterConfig localconfig.Cluster, bccsp bccsp.BCCSP, ) (BlockPuller, error) }
type Bundle ¶
type Bundle interface { channelconfig.Resources }
Bundle defines the channelconfig resources interface
type ByteBufferTuple ¶
ByteBufferTuple is the byte slice tuple
func (*ByteBufferTuple) FromBytes ¶
func (bbt *ByteBufferTuple) FromBytes(bytes []byte) error
FromBytes unmarshals bytes to a buffer tuple
func (*ByteBufferTuple) ToBytes ¶
func (bbt *ByteBufferTuple) ToBytes() []byte
ToBytes marshals the buffer tuple to bytes
type ChainGetter ¶
type ChainGetter interface { // GetChain obtains the ChainSupport for the given channel. // Returns nil, false when the ChainSupport for the given channel // isn't found. GetChain(chainID string) *multichannel.ChainSupport }
ChainGetter obtains instances of ChainSupport for the given channel
type ConfigBlockValidator ¶
type ConfigBlockValidator struct { ConfigUpdateProposer ConfigUpdateProposer ValidatingChannel string Filters Filters Logger *flogging.FabricLogger }
ConfigBlockValidator struct
func (*ConfigBlockValidator) ValidateConfig ¶
func (cbv *ConfigBlockValidator) ValidateConfig(envelope *cb.Envelope) error
ValidateConfig validates config from envelope
type ConfigTxValidator ¶
ConfigTxValidator defines the configtx validator interface
type ConfigUpdateProposer ¶
type ConfigUpdateProposer interface {
ProposeConfigUpdate(channel string, configtx *cb.Envelope) (*cb.ConfigEnvelope, error)
}
ConfigUpdateProposer produces a ConfigEnvelope
type ConfigValidator ¶
ConfigValidator interface
type Consenter ¶
type Consenter struct { CreateChain func(chainName string) GetPolicyManager PolicyManagerRetriever Logger *flogging.FabricLogger Identity []byte Comm *cluster.AuthCommMgr Chains ChainGetter SignerSerializer SignerSerializer Registrar *multichannel.Registrar WALBaseDir string ClusterDialer *cluster.PredicateDialer Conf *localconfig.TopLevel Metrics *Metrics MetricsBFT *api.Metrics MetricsWalBFT *wal.Metrics BCCSP bccsp.BCCSP ClusterService *cluster.ClusterService }
Consenter implementation of the BFT smart based consenter
func New ¶
func New( pmr PolicyManagerRetriever, signerSerializer SignerSerializer, clusterDialer *cluster.PredicateDialer, conf *localconfig.TopLevel, srvConf comm.ServerConfig, srv *comm.GRPCServer, r *multichannel.Registrar, metricsProvider metrics.Provider, clusterMetrics *cluster.Metrics, BCCSP bccsp.BCCSP, ) *Consenter
New creates Consenter of type smart bft
func (*Consenter) HandleChain ¶
func (c *Consenter) HandleChain(support consensus.ConsenterSupport, metadata *cb.Metadata) (consensus.Chain, error)
HandleChain returns a new Chain instance or an error upon failure
func (*Consenter) IsChannelMember ¶
func (*Consenter) ReceiverByChain ¶
func (c *Consenter) ReceiverByChain(channelID string) MessageReceiver
ReceiverByChain returns the MessageReceiver for the given channelID or nil if not found.
type ConsenterCertificate ¶
ConsenterCertificate denotes a TLS certificate of a consenter
func (ConsenterCertificate) IsConsenterOfChannel ¶
func (conCert ConsenterCertificate) IsConsenterOfChannel(configBlock *cb.Block) error
IsConsenterOfChannel returns whether the caller is a consenter of a channel by inspecting the given configuration block. It returns nil if true, else returns an error.
type ConsenterVerifier ¶
type ConsenterVerifier interface { // Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy Evaluate(signatureSet []*protoutil.SignedData) error }
ConsenterVerifier is used to determine whether a signature from one of the consenters is valid
type CounterConverter ¶
type CounterConverter struct {
// contains filtered or unexported fields
}
func (*CounterConverter) Add ¶
func (c *CounterConverter) Add(delta float64)
type Egress ¶
Egress implementation
func (*Egress) SendConsensus ¶
SendConsensus sends the BFT message to the cluster
func (*Egress) SendTransaction ¶
SendTransaction sends the transaction to the cluster
type EgressComm ¶
Comm enables the communications between the nodes.
type EgressCommFactory ¶
type EgressCommFactory func(runtimeConfig *atomic.Value, channelId string, comm cluster.Communicator) EgressComm
type GaugeConverter ¶
type GaugeConverter struct {
// contains filtered or unexported fields
}
func (*GaugeConverter) Add ¶
func (g *GaugeConverter) Add(delta float64)
func (*GaugeConverter) Set ¶
func (g *GaugeConverter) Set(value float64)
type HistogramConverter ¶
type HistogramConverter struct {
// contains filtered or unexported fields
}
func (*HistogramConverter) Observe ¶
func (h *HistogramConverter) Observe(value float64)
type Ingress ¶
type Ingress struct { Logger WarningLogger ChainSelector ReceiverGetter }
Ingress dispatches Submit and Step requests to the designated per chain instances
func (*Ingress) OnConsensus ¶
OnConsensus notifies the Ingress for a reception of a StepRequest from a given sender on a given channel
type Ledger ¶
type Ledger interface { // Height returns the number of blocks in the ledger this channel is associated with. Height() uint64 // Block returns a block with the given number, // or nil if such a block doesn't exist. Block(number uint64) *cb.Block }
Ledger returns the height and a block with the given number
type Logger ¶
type Logger interface { Warnf(template string, args ...interface{}) Panicf(template string, args ...interface{}) }
Logger specifies the logger
type MessageReceiver ¶
type MessageReceiver interface { HandleMessage(sender uint64, m *protos.Message) HandleRequest(sender uint64, req []byte) }
MessageReceiver receives messages
type MetricProviderConverter ¶
func (*MetricProviderConverter) NewCounter ¶
func (m *MetricProviderConverter) NewCounter(opts api.CounterOpts) api.Counter
func (*MetricProviderConverter) NewGauge ¶
func (m *MetricProviderConverter) NewGauge(opts api.GaugeOpts) api.Gauge
func (*MetricProviderConverter) NewHistogram ¶
func (m *MetricProviderConverter) NewHistogram(opts api.HistogramOpts) api.Histogram
type Metrics ¶
type Metrics struct { ClusterSize metrics.Gauge CommittedBlockNumber metrics.Gauge IsLeader metrics.Gauge LeaderID metrics.Gauge }
Metrics defines the metrics for the cluster.
type NodeIdentitiesByID ¶
NodeIdentitiesByID stores Identities by id
func (NodeIdentitiesByID) IdentityToID ¶
func (nibd NodeIdentitiesByID) IdentityToID(identity []byte) (uint64, bool)
IdentityToID looks up the Identity in NodeIdentitiesByID and returns id and flag true if found
type PolicyManagerRetriever ¶
PolicyManagerRetriever is the policy manager retriever function
type RPC ¶
type RPC interface { SendConsensus(dest uint64, msg *ab.ConsensusRequest) error // SendSubmit(dest uint64, request *ab.SubmitRequest) error SendSubmit(destination uint64, request *ab.SubmitRequest, report func(error)) error }
RPC sends a consensus and submits a request
type ReceiverGetter ¶
type ReceiverGetter interface { // ReceiverByChain returns the MessageReceiver if it exists, or nil if it doesn't ReceiverByChain(channelID string) MessageReceiver }
ReceiverGetter obtains instances of MessageReceiver given a channel ID
type RequestInspector ¶
type RequestInspector struct { ValidateIdentityStructure func(identity *msp.SerializedIdentity) error Logger *flogging.FabricLogger }
RequestInspector inspects incomming requests and validates serialized identity
func (*RequestInspector) RequestID ¶
func (ri *RequestInspector) RequestID(rawReq []byte) types.RequestInfo
RequestID unwraps the request info from the raw request
type RuntimeConfig ¶
type RuntimeConfig struct { BFTConfig types.Configuration LastCommittedBlockHash string RemoteNodes []cluster.RemoteNode ID2Identities NodeIdentitiesByID LastBlock *cb.Block LastConfigBlock *cb.Block Nodes []uint64 // contains filtered or unexported fields }
RuntimeConfig defines the configuration of the consensus that is related to runtime.
func (RuntimeConfig) BlockCommitted ¶
func (rtc RuntimeConfig) BlockCommitted(block *cb.Block, bccsp bccsp.BCCSP) (RuntimeConfig, error)
BlockCommitted updates the config from the block
type Signature ¶
Signature implementation
type Signer ¶
type Signer struct { ID uint64 SignerSerializer SignerSerializer Logger Logger LastConfigBlockNum func(*cb.Block) uint64 }
Signer implementation
type SignerSerializer ¶
type SignerSerializer interface { identity.SignerSerializer }
SignerSerializer signs messages and serializes identities
type SyncBuffer ¶
type SyncBuffer struct {
// contains filtered or unexported fields
}
func NewSyncBuffer ¶
func NewSyncBuffer(capacity uint) *SyncBuffer
func (*SyncBuffer) HandleBlock ¶
func (sb *SyncBuffer) HandleBlock(channelID string, block *common.Block) error
HandleBlock gives the block to the next stage of processing after fetching it from a remote orderer.
func (*SyncBuffer) Stop ¶
func (sb *SyncBuffer) Stop()
type Synchronizer ¶
type Synchronizer struct { LatestConfig func() (types.Configuration, []uint64) BlockToDecision func(*cb.Block) *types.Decision OnCommit func(*cb.Block) types.Reconfig Support consensus.ConsenterSupport CryptoProvider bccsp.BCCSP ClusterDialer *cluster.PredicateDialer LocalConfigCluster localconfig.Cluster BlockPullerFactory BlockPullerFactory Logger *flogging.FabricLogger // contains filtered or unexported fields }
Synchronizer implementation
func (*Synchronizer) Sync ¶
func (s *Synchronizer) Sync() types.SyncResponse
Sync synchronizes blocks and returns the response
type SynchronizerFactory ¶
type SynchronizerFactory interface { // CreateSynchronizer creates a new Synchronizer. CreateSynchronizer( logger *flogging.FabricLogger, localConfigCluster localconfig.Cluster, rtc RuntimeConfig, blockToDecision func(block *cb.Block) *types.Decision, pruneCommittedRequests func(block *cb.Block), updateRuntimeConfig func(block *cb.Block) types.Reconfig, support consensus.ConsenterSupport, bccsp bccsp.BCCSP, clusterDialer *cluster.PredicateDialer, ) api.Synchronizer }
type Verifier ¶
type Verifier struct { Channel string RuntimeConfig *atomic.Value ReqInspector *RequestInspector ConsenterVerifier ConsenterVerifier AccessController AccessController VerificationSequencer Sequencer Ledger Ledger Logger *flogging.FabricLogger ConfigValidator ConfigValidator }
Verifier verifies proposals and signatures
func (*Verifier) AuxiliaryData ¶
AuxiliaryData unmarshals and returns auxiliary data from signature
func (*Verifier) RequestsFromProposal ¶
func (v *Verifier) RequestsFromProposal(proposal types.Proposal) []types.RequestInfo
RequestsFromProposal converts proposal to []RequestInfo
func (*Verifier) VerificationSequence ¶
VerificationSequence returns verification sequence
func (*Verifier) VerifyConsenterSig ¶
func (v *Verifier) VerifyConsenterSig(signature types.Signature, prop types.Proposal) ([]byte, error)
VerifyConsenterSig verifies consenter signature
func (*Verifier) VerifyProposal ¶
VerifyProposal verifies proposal and returns []RequestInfo
func (*Verifier) VerifyRequest ¶
func (v *Verifier) VerifyRequest(rawRequest []byte) (types.RequestInfo, error)
VerifyRequest verifies raw request
type VerifierFactory ¶
type VerifierFactory interface { CreateBlockVerifier( configBlock *cb.Block, lastBlock *cb.Block, cryptoProvider bccsp.BCCSP, lg *flogging.FabricLogger, ) (deliverclient.CloneableUpdatableBlockVerifier, error) }
type WALConfig ¶
type WALConfig struct { WALDir string // WAL data of <my-channel> is stored in WALDir/<my-channel> SnapDir string // Snapshots of <my-channel> are stored in SnapDir/<my-channel> EvictionSuspicion string // Duration threshold that the node samples in order to suspect its eviction from the channel. }
WALConfig consensus specific configuration parameters from orderer.yaml; for SmartBFT only WALDir is relevant.
type WarningLogger ¶
type WarningLogger interface {
Warningf(template string, args ...interface{})
}