Documentation
¶
Index ¶
- Constants
- Variables
- func IsTLSConfigEqual(c1, c2 *cryptotls.Config) bool
- func LoadTLSConfig(config *ConnectionConfig) (*cryptotls.Config, error)
- func NewIdentitySigner(config *IdentityConfig) (msp.SigningIdentity, error)
- type BroadcastStream
- type Client
- type Config
- type ConnFilter
- type ConnectionConfig
- type ConsensusType
- type DeliverCftClient
- type DeliverConfig
- type DeliverStream
- type EnvelopedStream
- type IdentityConfig
- type OrdererConnectionManager
- func (c *OrdererConnectionManager) Close()
- func (c *OrdererConnectionManager) GetConnection(filters ...ConnFilter) (*grpc.ClientConn, uint64)
- func (c *OrdererConnectionManager) GetConnectionPerID(filters ...ConnFilter) (map[uint32]*grpc.ClientConn, uint64)
- func (c *OrdererConnectionManager) IsStale(configVersion uint64) bool
- func (c *OrdererConnectionManager) Update(config *ConnectionConfig) error
Constants ¶
const ( // Cft client support for crash fault tolerance. Cft ConsensusType = "CFT" // Bft client support for byzantine fault tolerance. Bft = "BFT" // DefaultConsensus default fault tolerance. DefaultConsensus = Cft // Broadcast support by endpoint. Broadcast = "broadcast" // Deliver support by endpoint. Deliver = "deliver" )
const MaxBlockNum uint64 = math.MaxUint64
MaxBlockNum is used for endless deliver.
Variables ¶
var ( ErrEmptyConnectionConfig = errors.New("empty connection config") ErrEmptyEndpoint = errors.New("empty endpoint") ErrNoEndpoints = errors.New("no endpoints") )
Errors that may be returned when updating a configuration.
var ErrNoConnections = errors.New("no connections found")
ErrNoConnections may be returned when trying to get the next connection.
Functions ¶
func IsTLSConfigEqual ¶
IsTLSConfigEqual returns true of the two configurations are equal.
func LoadTLSConfig ¶
func LoadTLSConfig(config *ConnectionConfig) (*cryptotls.Config, error)
LoadTLSConfig returns TLS configuration for connections.
func NewIdentitySigner ¶
func NewIdentitySigner(config *IdentityConfig) (msp.SigningIdentity, error)
NewIdentitySigner instantiate a signer for the given identity.
Types ¶
type BroadcastStream ¶
BroadcastStream can be either CFT or BFT broadcast.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a collection of nodes and their connections.
func New ¶
New creates a broadcast/deliver client. It must be closed to release all the associated connections.
func (*Client) Broadcast ¶
func (s *Client) Broadcast(ctx context.Context) (*EnvelopedStream, error)
Broadcast creates a broadcast stream.
func (*Client) Deliver ¶
func (s *Client) Deliver(ctx context.Context, deliverConfig *DeliverConfig) error
Deliver starts the block receiver. The call to Deliver blocks until an error occurs or the context is canceled.
func (*Client) UpdateConnections ¶
func (s *Client) UpdateConnections(config *ConnectionConfig) error
UpdateConnections updates the connection config.
type Config ¶
type Config struct {
Connection ConnectionConfig `mapstructure:"connection"`
ConsensusType ConsensusType `mapstructure:"consensus-type"`
ChannelID string `mapstructure:"channel-id"`
Identity *IdentityConfig `mapstructure:"identity"`
}
Config for the orderer-client.
type ConnFilter ¶
type ConnFilter struct {
// contains filtered or unexported fields
}
ConnFilter is used to filter connections.
type ConnectionConfig ¶
type ConnectionConfig struct {
Endpoints []*connection.OrdererEndpoint `mapstructure:"endpoints"`
Retry *connection.RetryProfile `mapstructure:"reconnect"`
RootCA [][]byte `mapstructure:"root-ca"`
// RootCAPaths The path to the root CAs (alternative to the raw data).
RootCAPaths []string `mapstructure:"root-ca-paths"`
}
ConnectionConfig contains the endpoints, CAs, and retry profile.
type DeliverCftClient ¶
type DeliverCftClient struct {
ConnectionManager *OrdererConnectionManager
Signer protoutil.Signer
ChannelID string
StreamCreator func(ctx context.Context, conn grpc.ClientConnInterface) (DeliverStream, error)
}
DeliverCftClient allows delivering blocks from one connection at a time. If one connection fails, it will try to connect to another one.
func (*DeliverCftClient) Deliver ¶
func (c *DeliverCftClient) Deliver(ctx context.Context, config *DeliverConfig) error
Deliver start receiving blocks starting from config.StartBlkNum to config.OutputBlock. The value of config.StartBlkNum is updated with the latest block number.
type DeliverConfig ¶
DeliverConfig holds the configuration needed for deliver to run.
type DeliverStream ¶
type DeliverStream interface {
Send(*common.Envelope) error
RecvBlockOrStatus() (*common.Block, *common.Status, error)
Context() context.Context
}
DeliverStream requires the following interface.
type EnvelopedStream ¶
type EnvelopedStream struct {
BroadcastStream
// contains filtered or unexported fields
}
EnvelopedStream implements broadcast, with the addition of automatically signing the envelope.
func (*EnvelopedStream) CreateEnvelope ¶
CreateEnvelope wraps a payload with an envelope, and signs it.
func (*EnvelopedStream) SendWithEnv ¶
func (s *EnvelopedStream) SendWithEnv(dataMsg proto.Message) (string, error)
SendWithEnv wraps a payload with an envelope, signs it and send it to the stream.
type IdentityConfig ¶
type IdentityConfig struct {
SignedEnvelopes bool `mapstructure:"signed-envelopes" yaml:"signed-envelopes"`
// MspID indicates to which MSP this client belongs to.
MspID string `mapstructure:"msp-id" yaml:"msp-id"`
MSPDir string `mapstructure:"msp-dir" yaml:"msp-dir"`
BCCSP *factory.FactoryOpts `mapstructure:"bccsp" yaml:"bccsp"`
}
IdentityConfig defines the orderer's MSP.
type OrdererConnectionManager ¶
type OrdererConnectionManager struct {
// contains filtered or unexported fields
}
OrdererConnectionManager packs all the orderer connections. Its connections can be updated via the Update() method. This will increase the config version, allowing a connection instance to identify a connection update and fetch the new connections.
func (*OrdererConnectionManager) Close ¶
func (c *OrdererConnectionManager) Close()
Close closes all the connections.
func (*OrdererConnectionManager) GetConnection ¶
func (c *OrdererConnectionManager) GetConnection(filters ...ConnFilter) (*grpc.ClientConn, uint64)
GetConnection returns a connection given filters.
func (*OrdererConnectionManager) GetConnectionPerID ¶
func (c *OrdererConnectionManager) GetConnectionPerID(filters ...ConnFilter) (map[uint32]*grpc.ClientConn, uint64)
GetConnectionPerID returns a connection given filters per ID.
func (*OrdererConnectionManager) IsStale ¶
func (c *OrdererConnectionManager) IsStale(configVersion uint64) bool
IsStale checks if the given OrdererConnectionResiliencyManager is stale. If nil is given, it returns true.
func (*OrdererConnectionManager) Update ¶
func (c *OrdererConnectionManager) Update(config *ConnectionConfig) error
Update updates the connection configs. This will close all connections, forcing the clients to reload.