...

Package cluster

import "github.com/hyperledger/fabric/orderer/common/cluster"
Overview
Index
Subdirectories

Overview ▾

Index ▾

Constants
Variables
func AnyChannel(_ string) bool
func BlockToString(block *common.Block) string
func ChannelCreationBlockToGenesisBlock(block *common.Block) (*common.Block, error)
func ConfigFromBlock(block *common.Block) (*common.ConfigEnvelope, error)
func DERtoPEM(der []byte) string
func IsNewChannelBlock(block *common.Block) (string, error)
func LastConfigBlock(block *common.Block, blockRetriever BlockRetriever) (*common.Block, error)
func NewStreamsByType() map[OperationType]map[uint64]*Stream
func Participant(puller ChainPuller, analyzeLastConfBlock SelfMembershipPredicate) error
func PullLastConfigBlock(puller ChainPuller) (*common.Block, error)
func SignatureSetFromBlock(block *common.Block) ([]*common.SignedData, error)
func VerifyBlockHash(indexInBuffer int, blockBuff []*common.Block) error
func VerifyBlockSignature(block *common.Block, verifier BlockVerifier, config *common.ConfigEnvelope) error
func VerifyBlocks(blockBuff []*common.Block, signatureVerifier BlockVerifier) error
type BlockCommitFunc
type BlockPuller
    func BlockPullerFromConfigBlock(conf PullerConfig, block *common.Block, verifierRetriever VerifierRetriever) (*BlockPuller, error)
    func (p *BlockPuller) Clone() *BlockPuller
    func (p *BlockPuller) Close()
    func (p *BlockPuller) HeightsByEndpoints() (map[string]uint64, error)
    func (p *BlockPuller) PullBlock(seq uint64) *common.Block
type BlockRetriever
type BlockSequenceVerifier
type BlockValidationPolicyVerifier
    func (bv *BlockValidationPolicyVerifier) VerifyBlockSignature(sd []*common.SignedData, envelope *common.ConfigEnvelope) error
type BlockVerifier
type BlockVerifierAssembler
    func (bva *BlockVerifierAssembler) VerifierFromConfig(configuration *common.ConfigEnvelope, channel string) (BlockVerifier, error)
type ChainInspector
    func (ci *ChainInspector) Channels() []ChannelGenesisBlock
    func (ci *ChainInspector) Close()
type ChainPuller
type ChannelExtractor
type ChannelGenesisBlock
type ChannelLister
type ChannelPredicate
type ClusterClient
type Comm
    func (c *Comm) Configure(channel string, newNodes []RemoteNode)
    func (c *Comm) DispatchConsensus(ctx context.Context, request *orderer.ConsensusRequest) error
    func (c *Comm) DispatchSubmit(ctx context.Context, request *orderer.SubmitRequest) error
    func (c *Comm) Remote(channel string, id uint64) (*RemoteContext, error)
    func (c *Comm) Shutdown()
type Communicator
type ConnByCertMap
    func (cbc ConnByCertMap) Lookup(cert []byte) (*grpc.ClientConn, bool)
    func (cbc ConnByCertMap) Put(cert []byte, conn *grpc.ClientConn)
    func (cbc ConnByCertMap) Remove(cert []byte)
    func (cbc ConnByCertMap) Size() int
type ConnectionMapper
type ConnectionStore
    func NewConnectionStore(dialer SecureDialer, tlsConnectionCount metrics.Gauge) *ConnectionStore
    func (c *ConnectionStore) Connection(endpoint string, expectedServerCert []byte) (*grpc.ClientConn, error)
    func (c *ConnectionStore) Disconnect(expectedServerCert []byte)
type Dialer
type Dispatcher
type EndpointCriteria
    func EndpointconfigFromConfigBlock(block *common.Block) ([]EndpointCriteria, error)
type GenesisBlocks
    func (gbs GenesisBlocks) Names() []string
type Handler
type ImpatientStream
    func (stream *ImpatientStream) Recv() (*orderer.DeliverResponse, error)
type ImpatientStreamCreator
    func NewImpatientStream(conn *grpc.ClientConn, waitTimeout time.Duration) ImpatientStreamCreator
type LedgerFactory
type LedgerInterceptor
    func (interceptor *LedgerInterceptor) Append(block *common.Block) error
type LedgerWriter
type MemberMapping
    func (mp MemberMapping) ByID(ID uint64) *Stub
    func (mp MemberMapping) LookupByClientCert(cert []byte) *Stub
    func (mp MemberMapping) Put(stub *Stub)
    func (mp MemberMapping) ServerCertificates() StringSet
type MembersByChannel
type Metrics
    func NewMetrics(provider MetricsProvider) *Metrics
type MetricsProvider
type NoopBlockVerifier
    func (*NoopBlockVerifier) VerifyBlockSignature(sd []*common.SignedData, config *common.ConfigEnvelope) error
type OperationType
type PredicateDialer
    func (dialer *PredicateDialer) Dial(address string, verifyFunc RemoteVerifier) (*grpc.ClientConn, error)
    func (dialer *PredicateDialer) UpdateRootCAs(serverRootCAs [][]byte)
type PullerConfig
    func PullerConfigFromTopLevelConfig(systemChannel string, conf *localconfig.TopLevel, tlsKey, tlsCert []byte, signer crypto.LocalSigner) PullerConfig
type RPC
    func (s *RPC) SendConsensus(destination uint64, msg *orderer.ConsensusRequest) error
    func (s *RPC) SendSubmit(destination uint64, request *orderer.SubmitRequest) error
type RemoteContext
    func (rc *RemoteContext) Abort()
    func (rc *RemoteContext) NewStream(timeout time.Duration) (*Stream, error)
type RemoteNode
    func (rm RemoteNode) String() string
type RemoteVerifier
type Replicator
    func (r *Replicator) IsReplicationNeeded() (bool, error)
    func (r *Replicator) PullChannel(channel string) error
    func (r *Replicator) ReplicateChains() []string
type SecureDialer
type SelfMembershipPredicate
type Service
    func (s *Service) Step(stream orderer.Cluster_StepServer) error
type StandardDialer
    func (dialer *StandardDialer) Dial(endpointCriteria EndpointCriteria) (*grpc.ClientConn, error)
type StepClient
type StepStream
type Stream
    func (stream *Stream) Canceled() bool
    func (stream *Stream) Recv() (*orderer.StepResponse, error)
    func (stream *Stream) Send(request *orderer.StepRequest) error
type StreamCountReporter
    func (scr *StreamCountReporter) Decrement()
    func (scr *StreamCountReporter) Increment()
type StreamOperation
type StringSet
type Stub
    func (stub *Stub) Activate(createRemoteContext func() (*RemoteContext, error)) error
    func (stub *Stub) Active() bool
    func (stub *Stub) Deactivate()
type VerificationRegistry
    func (vr *VerificationRegistry) BlockCommitted(block *common.Block, channel string)
    func (vr *VerificationRegistry) RegisterVerifier(chain string)
    func (vr *VerificationRegistry) RetrieveVerifier(channel string) BlockVerifier
type VerifierFactory
type VerifierRetriever

Package files

comm.go connections.go deliver.go metrics.go replication.go rpc.go service.go util.go

Constants

const (
    // MinimumExpirationWarningInterval is the default minimum time interval
    // between consecutive warnings about certificate expiration.
    MinimumExpirationWarningInterval = time.Minute * 5
)
const (
    // RetryTimeout is the time the block puller retries.
    RetryTimeout = time.Second * 10
)

Variables

var (
    EgressQueueLengthOpts = metrics.GaugeOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "egress_queue_length",
        Help:         "Length of the egress queue.",
        LabelNames:   []string{"host", "msg_type", "channel"},
        StatsdFormat: "%{#fqname}.%{host}.%{msg_type}.%{channel}",
    }

    EgressQueueCapacityOpts = metrics.GaugeOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "egress_queue_capacity",
        Help:         "Capacity of the egress queue.",
        LabelNames:   []string{"host", "msg_type", "channel"},
        StatsdFormat: "%{#fqname}.%{host}.%{msg_type}.%{channel}",
    }

    EgressWorkersOpts = metrics.GaugeOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "egress_queue_workers",
        Help:         "Count of egress queue workers.",
        LabelNames:   []string{"channel"},
        StatsdFormat: "%{#fqname}.%{channel}",
    }

    IngressStreamsCountOpts = metrics.GaugeOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "ingress_stream_count",
        Help:         "Count of streams from other nodes.",
        StatsdFormat: "%{#fqname}",
    }

    EgressStreamsCountOpts = metrics.GaugeOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "egress_stream_count",
        Help:         "Count of streams to other nodes.",
        LabelNames:   []string{"channel"},
        StatsdFormat: "%{#fqname}.%{channel}",
    }

    EgressTLSConnectionCountOpts = metrics.GaugeOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "egress_tls_connection_count",
        Help:         "Count of TLS connections to other nodes.",
        StatsdFormat: "%{#fqname}",
    }

    MessageSendTimeOpts = metrics.HistogramOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "msg_send_time",
        Help:         "The time it takes to send a message in seconds.",
        LabelNames:   []string{"host", "channel"},
        StatsdFormat: "%{#fqname}.%{host}.%{channel}",
    }

    MessagesDroppedCountOpts = metrics.CounterOpts{
        Namespace:    "cluster",
        Subsystem:    "comm",
        Name:         "msg_dropped_count",
        Help:         "Count of messages dropped.",
        LabelNames:   []string{"host", "channel"},
        StatsdFormat: "%{#fqname}.%{host}.%{channel}",
    }
)

ErrForbidden denotes that an ordering node refuses sending blocks due to access control.

var ErrForbidden = errors.New("forbidden pulling the channel")

ErrNotInChannel denotes that an ordering node is not in the channel

var ErrNotInChannel = errors.New("not in the channel")
var ErrRetryCountExhausted = errors.New("retry attempts exhausted")

ErrServiceUnavailable denotes that an ordering node is not servicing at the moment.

var ErrServiceUnavailable = errors.New("service unavailable")

ErrSkipped denotes that replicating a chain was skipped

var ErrSkipped = errors.New("skipped")

func AnyChannel

func AnyChannel(_ string) bool

AnyChannel accepts all channels.

func BlockToString

func BlockToString(block *common.Block) string

BlockToString returns a string representation of this block.

func ChannelCreationBlockToGenesisBlock

func ChannelCreationBlockToGenesisBlock(block *common.Block) (*common.Block, error)

ChannelCreationBlockToGenesisBlock converts a channel creation block to a genesis block

func ConfigFromBlock

func ConfigFromBlock(block *common.Block) (*common.ConfigEnvelope, error)

ConfigFromBlock returns a ConfigEnvelope if exists, or a *NotAConfigBlock error. It may also return some other error in case parsing failed.

func DERtoPEM

func DERtoPEM(der []byte) string

DERtoPEM returns a PEM representation of the DER encoded certificate

func IsNewChannelBlock

func IsNewChannelBlock(block *common.Block) (string, error)

IsNewChannelBlock returns a name of the channel in case it holds a channel create transaction, or empty string otherwise.

func LastConfigBlock

func LastConfigBlock(block *common.Block, blockRetriever BlockRetriever) (*common.Block, error)

LastConfigBlock returns the last config block relative to the given block.

func NewStreamsByType

func NewStreamsByType() map[OperationType]map[uint64]*Stream

NewStreamsByType returns a mapping of operation type to a mapping of destination to stream.

func Participant

func Participant(puller ChainPuller, analyzeLastConfBlock SelfMembershipPredicate) error

Participant returns whether the caller participates in the chain. It receives a ChainPuller that should already be calibrated for the chain, and a SelfMembershipPredicate that is used to detect whether the caller should service the chain. It returns nil if the caller participates in the chain. It may return: ErrNotInChannel in case the caller doesn't participate in the chain. ErrForbidden in case the caller is forbidden from pulling the block. ErrServiceUnavailable in case all orderers reachable cannot complete the request. ErrRetryCountExhausted in case no orderer is reachable.

func PullLastConfigBlock

func PullLastConfigBlock(puller ChainPuller) (*common.Block, error)

PullLastConfigBlock pulls the last configuration block, or returns an error on failure.

func SignatureSetFromBlock

func SignatureSetFromBlock(block *common.Block) ([]*common.SignedData, error)

SignatureSetFromBlock creates a signature set out of a block.

func VerifyBlockHash

func VerifyBlockHash(indexInBuffer int, blockBuff []*common.Block) error

VerifyBlockHash verifies the hash chain of the block with the given index among the blocks of the given block buffer.

func VerifyBlockSignature

func VerifyBlockSignature(block *common.Block, verifier BlockVerifier, config *common.ConfigEnvelope) error

VerifyBlockSignature verifies the signature on the block with the given BlockVerifier and the given config.

func VerifyBlocks

func VerifyBlocks(blockBuff []*common.Block, signatureVerifier BlockVerifier) error

VerifyBlocks verifies the given consecutive sequence of blocks is valid, and returns nil if it's valid, else an error.

type BlockCommitFunc

BlockCommitFunc signals a block commit.

type BlockCommitFunc func(block *common.Block, channel string)

type BlockPuller

BlockPuller pulls blocks from remote ordering nodes. Its operations are not thread safe.

type BlockPuller struct {
    // Configuration
    MaxPullBlockRetries uint64
    MaxTotalBufferBytes int
    Signer              crypto.LocalSigner
    TLSCert             []byte
    Channel             string
    FetchTimeout        time.Duration
    RetryTimeout        time.Duration
    Logger              *flogging.FabricLogger
    Dialer              Dialer
    VerifyBlockSequence BlockSequenceVerifier
    Endpoints           []EndpointCriteria
    // contains filtered or unexported fields
}

func BlockPullerFromConfigBlock

func BlockPullerFromConfigBlock(conf PullerConfig, block *common.Block, verifierRetriever VerifierRetriever) (*BlockPuller, error)

BlockPullerFromConfigBlock returns a BlockPuller that doesn't verify signatures on blocks.

func (*BlockPuller) Clone

func (p *BlockPuller) Clone() *BlockPuller

Clone returns a copy of this BlockPuller initialized for the given channel

func (*BlockPuller) Close

func (p *BlockPuller) Close()

Close makes the BlockPuller close the connection and stream with the remote endpoint, and wipe the internal block buffer.

func (*BlockPuller) HeightsByEndpoints

func (p *BlockPuller) HeightsByEndpoints() (map[string]uint64, error)

HeightsByEndpoints returns the block heights by endpoints of orderers

func (*BlockPuller) PullBlock

func (p *BlockPuller) PullBlock(seq uint64) *common.Block

PullBlock blocks until a block with the given sequence is fetched from some remote ordering node, or until consecutive failures of fetching the block exceed MaxPullBlockRetries.

type BlockRetriever

BlockRetriever retrieves blocks

type BlockRetriever interface {
    // Block returns a block with the given number,
    // or nil if such a block doesn't exist.
    Block(number uint64) *common.Block
}

type BlockSequenceVerifier

BlockSequenceVerifier verifies that the given consecutive sequence of blocks is valid.

type BlockSequenceVerifier func(blocks []*common.Block, channel string) error

type BlockValidationPolicyVerifier

BlockValidationPolicyVerifier verifies signatures based on the block validation policy.

type BlockValidationPolicyVerifier struct {
    Logger    *flogging.FabricLogger
    Channel   string
    PolicyMgr policies.Manager
}

func (*BlockValidationPolicyVerifier) VerifyBlockSignature

func (bv *BlockValidationPolicyVerifier) VerifyBlockSignature(sd []*common.SignedData, envelope *common.ConfigEnvelope) error

VerifyBlockSignature verifies the signed data associated to a block, optionally with the given config envelope.

type BlockVerifier

BlockVerifier verifies block signatures.

type BlockVerifier interface {
    // VerifyBlockSignature verifies a signature of a block.
    // It has an optional argument of a configuration envelope
    // which would make the block verification to use validation rules
    // based on the given configuration in the ConfigEnvelope.
    // If the config envelope passed is nil, then the validation rules used
    // are the ones that were applied at commit of previous blocks.
    VerifyBlockSignature(sd []*common.SignedData, config *common.ConfigEnvelope) error
}

type BlockVerifierAssembler

BlockVerifierAssembler creates a BlockVerifier out of a config envelope

type BlockVerifierAssembler struct {
    Logger *flogging.FabricLogger
}

func (*BlockVerifierAssembler) VerifierFromConfig

func (bva *BlockVerifierAssembler) VerifierFromConfig(configuration *common.ConfigEnvelope, channel string) (BlockVerifier, error)

VerifierFromConfig creates a BlockVerifier from the given configuration.

type ChainInspector

ChainInspector walks over a chain

type ChainInspector struct {
    Logger          *flogging.FabricLogger
    Puller          ChainPuller
    LastConfigBlock *common.Block
}

func (*ChainInspector) Channels

func (ci *ChainInspector) Channels() []ChannelGenesisBlock

Channels returns the list of ChannelGenesisBlocks for all channels. Each such ChannelGenesisBlock contains the genesis block of the channel.

func (*ChainInspector) Close

func (ci *ChainInspector) Close()

Close closes the ChainInspector

type ChainPuller

ChainPuller pulls blocks from a chain

type ChainPuller interface {
    // PullBlock pulls the given block from some orderer node
    PullBlock(seq uint64) *common.Block

    // HeightsByEndpoints returns the block heights by endpoints of orderers
    HeightsByEndpoints() (map[string]uint64, error)

    // Close closes the ChainPuller
    Close()
}

type ChannelExtractor

ChannelExtractor extracts the channel of a given message, or returns an empty string if that's not possible

type ChannelExtractor interface {
    TargetChannel(message proto.Message) string
}

type ChannelGenesisBlock

ChannelGenesisBlock wraps a Block and its channel name

type ChannelGenesisBlock struct {
    ChannelName  string
    GenesisBlock *common.Block
}

type ChannelLister

ChannelLister returns a list of channels

type ChannelLister interface {
    // Channels returns a list of channels
    Channels() []ChannelGenesisBlock
    // Close closes the ChannelLister
    Close()
}

type ChannelPredicate

ChannelPredicate accepts channels according to their names.

type ChannelPredicate func(channelName string) bool

type ClusterClient

ClusterClient creates streams that point to a remote cluster member.

type ClusterClient interface {
    Step(ctx context.Context, opts ...grpc.CallOption) (orderer.Cluster_StepClient, error)
}

type Comm

Comm implements Communicator

type Comm struct {
    MinimumExpirationWarningInterval time.Duration
    CertExpWarningThreshold          time.Duration

    SendBufferSize int
    Lock           sync.RWMutex
    Logger         *flogging.FabricLogger
    ChanExt        ChannelExtractor
    H              Handler
    Connections    *ConnectionStore
    Chan2Members   MembersByChannel
    Metrics        *Metrics
    // contains filtered or unexported fields
}

func (*Comm) Configure

func (c *Comm) Configure(channel string, newNodes []RemoteNode)

Configure configures the channel with the given RemoteNodes

func (*Comm) DispatchConsensus

func (c *Comm) DispatchConsensus(ctx context.Context, request *orderer.ConsensusRequest) error

DispatchConsensus identifies the channel and sender of the step request and passes it to the underlying Handler

func (*Comm) DispatchSubmit

func (c *Comm) DispatchSubmit(ctx context.Context, request *orderer.SubmitRequest) error

DispatchSubmit identifies the channel and sender of the submit request and passes it to the underlying Handler

func (*Comm) Remote

func (c *Comm) Remote(channel string, id uint64) (*RemoteContext, error)

Remote obtains a RemoteContext linked to the destination node on the context of a given channel

func (*Comm) Shutdown

func (c *Comm) Shutdown()

Shutdown shuts down the instance

type Communicator

Communicator defines communication for a consenter

type Communicator interface {
    // Remote returns a RemoteContext for the given RemoteNode ID in the context
    // of the given channel, or error if connection cannot be established, or
    // the channel wasn't configured
    Remote(channel string, id uint64) (*RemoteContext, error)
    // Configure configures the communication to connect to all
    // given members, and disconnect from any members not among the given
    // members.
    Configure(channel string, members []RemoteNode)
    // Shutdown shuts down the communicator
    Shutdown()
}

type ConnByCertMap

ConnByCertMap maps certificates represented as strings to gRPC connections

type ConnByCertMap map[string]*grpc.ClientConn

func (ConnByCertMap) Lookup

func (cbc ConnByCertMap) Lookup(cert []byte) (*grpc.ClientConn, bool)

Lookup looks up a certificate and returns the connection that was mapped to the certificate, and whether it was found or not

func (ConnByCertMap) Put

func (cbc ConnByCertMap) Put(cert []byte, conn *grpc.ClientConn)

Put associates the given connection to the certificate

func (ConnByCertMap) Remove

func (cbc ConnByCertMap) Remove(cert []byte)

Remove removes the connection that is associated to the given certificate

func (ConnByCertMap) Size

func (cbc ConnByCertMap) Size() int

type ConnectionMapper

ConnectionMapper maps certificates to connections

type ConnectionMapper interface {
    Lookup(cert []byte) (*grpc.ClientConn, bool)
    Put(cert []byte, conn *grpc.ClientConn)
    Remove(cert []byte)
    Size() int
}

type ConnectionStore

ConnectionStore stores connections to remote nodes

type ConnectionStore struct {
    Connections ConnectionMapper
    // contains filtered or unexported fields
}

func NewConnectionStore

func NewConnectionStore(dialer SecureDialer, tlsConnectionCount metrics.Gauge) *ConnectionStore

NewConnectionStore creates a new ConnectionStore with the given SecureDialer

func (*ConnectionStore) Connection

func (c *ConnectionStore) Connection(endpoint string, expectedServerCert []byte) (*grpc.ClientConn, error)

Connection obtains a connection to the given endpoint and expects the given server certificate to be presented by the remote node

func (*ConnectionStore) Disconnect

func (c *ConnectionStore) Disconnect(expectedServerCert []byte)

Disconnect closes the gRPC connection that is mapped to the given certificate

type Dialer

Dialer creates a gRPC connection to a remote address

type Dialer interface {
    Dial(endpointCriteria EndpointCriteria) (*grpc.ClientConn, error)
}

type Dispatcher

Dispatcher dispatches requests

type Dispatcher interface {
    DispatchSubmit(ctx context.Context, request *orderer.SubmitRequest) error
    DispatchConsensus(ctx context.Context, request *orderer.ConsensusRequest) error
}

type EndpointCriteria

EndpointCriteria defines criteria of how to connect to a remote orderer node.

type EndpointCriteria struct {
    Endpoint   string   // Endpoint of the form host:port
    TLSRootCAs [][]byte // PEM encoded TLS root CA certificates
}

func EndpointconfigFromConfigBlock

func EndpointconfigFromConfigBlock(block *common.Block) ([]EndpointCriteria, error)

EndpointconfigFromConfigBlock retrieves TLS CA certificates and endpoints from a config block.

type GenesisBlocks

GenesisBlocks aggregates several ChannelGenesisBlocks

type GenesisBlocks []ChannelGenesisBlock

func (GenesisBlocks) Names

func (gbs GenesisBlocks) Names() []string

Names returns the channel names all ChannelGenesisBlocks

type Handler

Handler handles Step() and Submit() requests and returns a corresponding response

type Handler interface {
    OnConsensus(channel string, sender uint64, req *orderer.ConsensusRequest) error
    OnSubmit(channel string, sender uint64, req *orderer.SubmitRequest) error
}

type ImpatientStream

ImpatientStream aborts the stream if it waits for too long for a message.

type ImpatientStream struct {
    orderer.AtomicBroadcast_DeliverClient
    // contains filtered or unexported fields
}

func (*ImpatientStream) Recv

func (stream *ImpatientStream) Recv() (*orderer.DeliverResponse, error)

Recv blocks until a response is received from the stream or the timeout expires.

type ImpatientStreamCreator

ImpatientStreamCreator creates an ImpatientStream

type ImpatientStreamCreator func() (*ImpatientStream, error)

func NewImpatientStream

func NewImpatientStream(conn *grpc.ClientConn, waitTimeout time.Duration) ImpatientStreamCreator

NewImpatientStream returns a ImpatientStreamCreator that creates impatientStreams.

type LedgerFactory

LedgerFactory retrieves or creates new ledgers by chainID

type LedgerFactory interface {
    // GetOrCreate gets an existing ledger (if it exists)
    // or creates it if it does not
    GetOrCreate(chainID string) (LedgerWriter, error)
}

type LedgerInterceptor

LedgerInterceptor intercepts block commits.

type LedgerInterceptor struct {
    Channel              string
    InterceptBlockCommit BlockCommitFunc
    LedgerWriter
}

func (*LedgerInterceptor) Append

func (interceptor *LedgerInterceptor) Append(block *common.Block) error

Append commits a block into the ledger, and also fires the configured callback.

type LedgerWriter

LedgerWriter allows the caller to write blocks and inspect the height

type LedgerWriter interface {
    // Append a new block to the ledger
    Append(block *common.Block) error

    // Height returns the number of blocks on the ledger
    Height() uint64
}

type MemberMapping

MemberMapping defines NetworkMembers by their ID

type MemberMapping map[uint64]*Stub

func (MemberMapping) ByID

func (mp MemberMapping) ByID(ID uint64) *Stub

ByID retrieves the Stub with the given ID from the MemberMapping

func (MemberMapping) LookupByClientCert

func (mp MemberMapping) LookupByClientCert(cert []byte) *Stub

LookupByClientCert retrieves a Stub with the given client certificate

func (MemberMapping) Put

func (mp MemberMapping) Put(stub *Stub)

Put inserts the given stub to the MemberMapping

func (MemberMapping) ServerCertificates

func (mp MemberMapping) ServerCertificates() StringSet

ServerCertificates returns a set of the server certificates represented as strings

type MembersByChannel

MembersByChannel is a mapping from channel name to MemberMapping

type MembersByChannel map[string]MemberMapping

type Metrics

Metrics defines the metrics for the cluster.

type Metrics struct {
    EgressQueueLength        metrics.Gauge
    EgressQueueCapacity      metrics.Gauge
    EgressWorkerCount        metrics.Gauge
    IngressStreamsCount      metrics.Gauge
    EgressStreamsCount       metrics.Gauge
    EgressTLSConnectionCount metrics.Gauge
    MessageSendTime          metrics.Histogram
    MessagesDroppedCount     metrics.Counter
}

func NewMetrics

func NewMetrics(provider MetricsProvider) *Metrics

NewMetrics initializes new metrics for the cluster infrastructure.

type MetricsProvider

A MetricsProvider is an abstraction for a metrics provider. It is a factory for Counter, Gauge, and Histogram meters.

type MetricsProvider interface {
    // NewCounter creates a new instance of a Counter.
    NewCounter(opts metrics.CounterOpts) metrics.Counter
    // NewGauge creates a new instance of a Gauge.
    NewGauge(opts metrics.GaugeOpts) metrics.Gauge
    // NewHistogram creates a new instance of a Histogram.
    NewHistogram(opts metrics.HistogramOpts) metrics.Histogram
}

type NoopBlockVerifier

NoopBlockVerifier doesn't verify block signatures

type NoopBlockVerifier struct{}

func (*NoopBlockVerifier) VerifyBlockSignature

func (*NoopBlockVerifier) VerifyBlockSignature(sd []*common.SignedData, config *common.ConfigEnvelope) error

VerifyBlockSignature accepts all signatures over blocks.

type OperationType

OperationType denotes a type of operation that the RPC can perform such as sending a transaction, or a consensus related message.

type OperationType int
const (
    ConsensusOperation OperationType = iota
    SubmitOperation
)

type PredicateDialer

PredicateDialer creates gRPC connections that are only established if the given predicate is fulfilled

type PredicateDialer struct {
    comm.ClientConfig
    // contains filtered or unexported fields
}

func (*PredicateDialer) Dial

func (dialer *PredicateDialer) Dial(address string, verifyFunc RemoteVerifier) (*grpc.ClientConn, error)

Dial creates a new gRPC connection that can only be established, if the remote node's certificate chain satisfy verifyFunc

func (*PredicateDialer) UpdateRootCAs

func (dialer *PredicateDialer) UpdateRootCAs(serverRootCAs [][]byte)

type PullerConfig

PullerConfig configures a BlockPuller.

type PullerConfig struct {
    TLSKey              []byte
    TLSCert             []byte
    Timeout             time.Duration
    Signer              crypto.LocalSigner
    Channel             string
    MaxTotalBufferBytes int
}

func PullerConfigFromTopLevelConfig

func PullerConfigFromTopLevelConfig(systemChannel string, conf *localconfig.TopLevel, tlsKey, tlsCert []byte, signer crypto.LocalSigner) PullerConfig

PullerConfigFromTopLevelConfig creates a PullerConfig from a TopLevel config, and from a signer and TLS key cert pair. The PullerConfig's channel is initialized to be the system channel.

type RPC

RPC performs remote procedure calls to remote cluster nodes.

type RPC struct {
    Logger  *flogging.FabricLogger
    Timeout time.Duration
    Channel string
    Comm    Communicator

    StreamsByType map[OperationType]map[uint64]*Stream
    // contains filtered or unexported fields
}

func (*RPC) SendConsensus

func (s *RPC) SendConsensus(destination uint64, msg *orderer.ConsensusRequest) error

Consensus passes the given ConsensusRequest message to the raft.Node instance.

func (*RPC) SendSubmit

func (s *RPC) SendSubmit(destination uint64, request *orderer.SubmitRequest) error

SendSubmit sends a SubmitRequest to the given destination node.

type RemoteContext

RemoteContext interacts with remote cluster nodes. Every call can be aborted via call to Abort()

type RemoteContext struct {
    Metrics      *Metrics
    Channel      string
    SendBuffSize int

    Logger *flogging.FabricLogger

    Client    orderer.ClusterClient
    ProbeConn func(conn *grpc.ClientConn) error
    // contains filtered or unexported fields
}

func (*RemoteContext) Abort

func (rc *RemoteContext) Abort()

Abort aborts the contexts the RemoteContext uses, thus effectively causes all operations that use this RemoteContext to terminate.

func (*RemoteContext) NewStream

func (rc *RemoteContext) NewStream(timeout time.Duration) (*Stream, error)

NewStream creates a new stream. It is not thread safe, and Send() or Recv() block only until the timeout expires.

type RemoteNode

RemoteNode represents a cluster member

type RemoteNode struct {
    // ID is unique among all members, and cannot be 0.
    ID uint64
    // Endpoint is the endpoint of the node, denoted in %s:%d format
    Endpoint string
    // ServerTLSCert is the DER encoded TLS server certificate of the node
    ServerTLSCert []byte
    // ClientTLSCert is the DER encoded TLS client certificate of the node
    ClientTLSCert []byte
}

func (RemoteNode) String

func (rm RemoteNode) String() string

String returns a string representation of this RemoteNode

type RemoteVerifier

RemoteVerifier verifies the connection to the remote host

type RemoteVerifier func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error

type Replicator

Replicator replicates chains

type Replicator struct {
    DoNotPanicIfClusterNotReachable bool
    Filter                          ChannelPredicate
    SystemChannel                   string
    ChannelLister                   ChannelLister
    Logger                          *flogging.FabricLogger
    Puller                          *BlockPuller
    BootBlock                       *common.Block
    AmIPartOfChannel                SelfMembershipPredicate
    LedgerFactory                   LedgerFactory
}

func (*Replicator) IsReplicationNeeded

func (r *Replicator) IsReplicationNeeded() (bool, error)

IsReplicationNeeded returns whether replication is needed, or the cluster node can resume standard boot flow.

func (*Replicator) PullChannel

func (r *Replicator) PullChannel(channel string) error

PullChannel pulls the given channel from some orderer, and commits it to the ledger.

func (*Replicator) ReplicateChains

func (r *Replicator) ReplicateChains() []string

ReplicateChains pulls chains and commits them. Returns the names of the chains replicated successfully.

type SecureDialer

SecureDialer connects to a remote address

type SecureDialer interface {
    Dial(address string, verifyFunc RemoteVerifier) (*grpc.ClientConn, error)
}

type SelfMembershipPredicate

SelfMembershipPredicate determines whether the caller is found in the given config block

type SelfMembershipPredicate func(configBlock *common.Block) error

type Service

Service defines the raft Service

type Service struct {
    StreamCountReporter              *StreamCountReporter
    Dispatcher                       Dispatcher
    Logger                           *flogging.FabricLogger
    StepLogger                       *flogging.FabricLogger
    MinimumExpirationWarningInterval time.Duration
    CertExpWarningThreshold          time.Duration
}

func (*Service) Step

func (s *Service) Step(stream orderer.Cluster_StepServer) error

Step passes an implementation-specific message to another cluster member.

type StandardDialer

StandardDialer wraps an AtomicClientConfig, and provides a means to connect according to given EndpointCriteria.

type StandardDialer struct {
    comm.ClientConfig
}

func (*StandardDialer) Dial

func (dialer *StandardDialer) Dial(endpointCriteria EndpointCriteria) (*grpc.ClientConn, error)

Dial dials an address according to the given EndpointCriteria

type StepClient

StepClient defines a client that sends and receives Step requests and responses.

type StepClient interface {
    Send(*orderer.StepRequest) error
    Recv() (*orderer.StepResponse, error)
    grpc.ClientStream
}

type StepStream

StepStream defines the gRPC stream for sending transactions, and receiving corresponding responses

type StepStream interface {
    Send(response *orderer.StepResponse) error
    Recv() (*orderer.StepRequest, error)
    grpc.ServerStream
}

type Stream

Stream is used to send/receive messages to/from the remote cluster member.

type Stream struct {
    ID       uint64
    Channel  string
    NodeName string
    Endpoint string
    Logger   *flogging.FabricLogger
    Timeout  time.Duration
    orderer.Cluster_StepClient
    Cancel func(error)
    // contains filtered or unexported fields
}

func (*Stream) Canceled

func (stream *Stream) Canceled() bool

Canceled returns whether the stream was canceled.

func (*Stream) Recv

func (stream *Stream) Recv() (*orderer.StepResponse, error)

Recv receives a message from a remote cluster member.

func (*Stream) Send

func (stream *Stream) Send(request *orderer.StepRequest) error

Send sends the given request to the remote cluster member.

type StreamCountReporter

StreamCountReporter reports the number of streams currently connected to this node

type StreamCountReporter struct {
    Metrics *Metrics
    // contains filtered or unexported fields
}

func (*StreamCountReporter) Decrement

func (scr *StreamCountReporter) Decrement()

func (*StreamCountReporter) Increment

func (scr *StreamCountReporter) Increment()

type StreamOperation

StreamOperation denotes an operation done by a stream, such a Send or Receive.

type StreamOperation func() (*orderer.StepResponse, error)

type StringSet

StringSet is a set of strings

type StringSet map[string]struct{}

type Stub

Stub holds all information about the remote node, including the RemoteContext for it, and serializes some operations on it.

type Stub struct {
    RemoteNode
    *RemoteContext
    // contains filtered or unexported fields
}

func (*Stub) Activate

func (stub *Stub) Activate(createRemoteContext func() (*RemoteContext, error)) error

Activate creates a remote context with the given function callback in an atomic manner - if two parallel invocations are invoked on this Stub, only a single invocation of createRemoteStub takes place.

func (*Stub) Active

func (stub *Stub) Active() bool

Active returns whether the Stub is active or not

func (*Stub) Deactivate

func (stub *Stub) Deactivate()

Deactivate deactivates the Stub and ceases all communication operations invoked on it.

type VerificationRegistry

VerificationRegistry registers verifiers and retrieves them.

type VerificationRegistry struct {
    LoadVerifier       func(chain string) BlockVerifier
    Logger             *flogging.FabricLogger
    VerifierFactory    VerifierFactory
    VerifiersByChannel map[string]BlockVerifier
}

func (*VerificationRegistry) BlockCommitted

func (vr *VerificationRegistry) BlockCommitted(block *common.Block, channel string)

BlockCommitted notifies the VerificationRegistry upon a block commit, which may trigger a registration of a verifier out of the block in case the block is a config block.

func (*VerificationRegistry) RegisterVerifier

func (vr *VerificationRegistry) RegisterVerifier(chain string)

RegisterVerifier adds a verifier into the registry if applicable.

func (*VerificationRegistry) RetrieveVerifier

func (vr *VerificationRegistry) RetrieveVerifier(channel string) BlockVerifier

RetrieveVerifier returns a BlockVerifier for the given channel, or nil if not found.

type VerifierFactory

VerifierFactory creates BlockVerifiers.

type VerifierFactory interface {
    // VerifierFromConfig creates a BlockVerifier from the given configuration.
    VerifierFromConfig(configuration *common.ConfigEnvelope, channel string) (BlockVerifier, error)
}

type VerifierRetriever

VerifierRetriever retrieves BlockVerifiers for channels.

type VerifierRetriever interface {
    // RetrieveVerifier retrieves a BlockVerifier for the given channel.
    RetrieveVerifier(channel string) BlockVerifier
}

Subdirectories

Name Synopsis
..
mocks