cluster

package
v2.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
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}",
	}
)
View Source
var ErrForbidden = errors.New("forbidden pulling the channel")

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

View Source
var ErrNotInChannel = errors.New("not in the channel")

ErrNotInChannel denotes that an ordering node is not in the channel

View Source
var ErrRetryCountExhausted = errors.New("retry attempts exhausted")
View Source
var ErrServiceUnavailable = errors.New("service unavailable")

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

View Source
var ErrSkipped = errors.New("skipped")

ErrSkipped denotes that replicating a chain was skipped

Functions

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) ([]*protoutil.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.

Types

type BlockCommitFunc

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

BlockCommitFunc signals a block commit.

type BlockPuller

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

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

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

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
}

BlockRetriever retrieves blocks

type BlockSequenceVerifier

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

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

type BlockValidationPolicyVerifier

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

BlockValidationPolicyVerifier verifies signatures based on the block validation policy.

func (*BlockValidationPolicyVerifier) VerifyBlockSignature

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

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

type BlockVerifier

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 []*protoutil.SignedData, config *common.ConfigEnvelope) error
}

BlockVerifier verifies block signatures.

type BlockVerifierAssembler

type BlockVerifierAssembler struct {
	Logger *flogging.FabricLogger
}

BlockVerifierAssembler creates a BlockVerifier out of a config envelope

func (*BlockVerifierAssembler) VerifierFromConfig

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

VerifierFromConfig creates a BlockVerifier from the given configuration.

type ChainInspector

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

ChainInspector walks over a chain

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

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()
}

ChainPuller pulls blocks from a chain

type ChannelExtractor

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

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

type ChannelGenesisBlock

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

ChannelGenesisBlock wraps a Block and its channel name

type ChannelLister

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

ChannelLister returns a list of channels

type ChannelPredicate

type ChannelPredicate func(channelName string) bool

ChannelPredicate accepts channels according to their names.

type ClusterClient

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

ClusterClient creates streams that point to a remote cluster member.

type Comm

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
}

Comm implements Communicator

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

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()
}

Communicator defines communication for a consenter

type ConnByCertMap

type ConnByCertMap map[string]*grpc.ClientConn

ConnByCertMap maps certificates represented as strings to gRPC connections

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

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

ConnectionMapper maps certificates to connections

type ConnectionStore

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

ConnectionStore stores connections to remote nodes

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

type Dialer interface {
	Dial(address string) (*grpc.ClientConn, error)
}

Dialer creates a gRPC connection to a remote address

type Dispatcher

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

Dispatcher dispatches requests

type EndpointConfig

type EndpointConfig struct {
	TLSRootCAs [][]byte
	Endpoints  []string
}

EndpointConfig defines a configuration of endpoints of ordering service nodes

func EndpointconfigFromConfigBlock

func EndpointconfigFromConfigBlock(block *common.Block) (*EndpointConfig, error)

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

type GenesisBlocks

type GenesisBlocks []ChannelGenesisBlock

GenesisBlocks aggregates several ChannelGenesisBlocks

func (GenesisBlocks) Names

func (gbs GenesisBlocks) Names() []string

Names returns the channel names all ChannelGenesisBlocks

type Handler

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

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

type ImpatientStream

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

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

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

type ImpatientStreamCreator func() (*ImpatientStream, error)

ImpatientStreamCreator creates an ImpatientStream

func NewImpatientStream

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

NewImpatientStream returns a ImpatientStreamCreator that creates impatientStreams.

type LedgerFactory

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

LedgerFactory retrieves or creates new ledgers by chainID

type LedgerInterceptor

type LedgerInterceptor struct {
	Channel              string
	InterceptBlockCommit BlockCommitFunc
	LedgerWriter
}

LedgerInterceptor intercepts block commits.

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

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
}

LedgerWriter allows the caller to write blocks and inspect the height

type MemberMapping

type MemberMapping map[uint64]*Stub

MemberMapping defines NetworkMembers by their ID

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

type MembersByChannel map[string]MemberMapping

MembersByChannel is a mapping from channel name to MemberMapping

type Metrics

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
}

Metrics defines the metrics for the cluster.

func NewMetrics

func NewMetrics(provider MetricsProvider) *Metrics

NewMetrics initializes new metrics for the cluster infrastructure.

type MetricsProvider

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
}

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

type NoopBlockVerifier

type NoopBlockVerifier struct{}

NoopBlockVerifier doesn't verify block signatures

func (*NoopBlockVerifier) VerifyBlockSignature

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

VerifyBlockSignature accepts all signatures over blocks.

type OperationType

type OperationType int

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

const (
	ConsensusOperation OperationType = iota
	SubmitOperation
)

type PredicateDialer

type PredicateDialer struct {
	Config atomic.Value
}

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

func NewTLSPinningDialer

func NewTLSPinningDialer(config comm.ClientConfig) *PredicateDialer

NewTLSPinningDialer creates a new PredicateDialer

func (*PredicateDialer) ClientConfig

func (dialer *PredicateDialer) ClientConfig() (comm.ClientConfig, error)

ClientConfig returns the comm.ClientConfig, or an error if they cannot be extracted.

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

func (dialer *PredicateDialer) SetConfig(config comm.ClientConfig)

SetConfig sets the configuration of the PredicateDialer

type PullerConfig

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

PullerConfig configures a BlockPuller.

func PullerConfigFromTopLevelConfig

func PullerConfigFromTopLevelConfig(
	systemChannel string,
	conf *localconfig.TopLevel,
	tlsKey,
	tlsCert []byte,
	signer identity.SignerSerializer,
) 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

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

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

RPC performs remote procedure calls to remote cluster nodes.

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

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
}

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

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

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
}

RemoteNode represents a cluster member

func (RemoteNode) String

func (rm RemoteNode) String() string

String returns a string representation of this RemoteNode

type RemoteVerifier

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

RemoteVerifier verifies the connection to the remote host

type Replicator

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

Replicator replicates chains

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

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

SecureDialer connects to a remote address

type SelfMembershipPredicate

type SelfMembershipPredicate func(configBlock *common.Block) error

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

type Service

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

Service defines the raft Service

func (*Service) Step

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

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

type StandardDialer

type StandardDialer struct {
	Dialer *PredicateDialer
}

StandardDialer wraps a PredicateDialer to a standard cluster.Dialer that passes in a nil verify function

func (*StandardDialer) Dial

func (bdp *StandardDialer) Dial(address string) (*grpc.ClientConn, error)

Dial dials to the given address

type StepClient

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

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

type StepStream

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

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

type Stream

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
}

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

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

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

StreamCountReporter reports the number of streams currently connected to this node

func (*StreamCountReporter) Decrement

func (scr *StreamCountReporter) Decrement()

func (*StreamCountReporter) Increment

func (scr *StreamCountReporter) Increment()

type StreamOperation

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

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

type StringSet

type StringSet map[string]struct{}

StringSet is a set of strings

type Stub

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

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

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

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

VerificationRegistry registers verifiers and retrieves them.

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

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

VerifierFactory creates BlockVerifiers.

type VerifierRetriever

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

VerifierRetriever retrieves BlockVerifiers for channels.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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