broadcastdeliver

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const MaxBlockNum uint64 = math.MaxUint64

MaxBlockNum is used for endless deliver.

Variables

View Source
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.

View Source
var ErrNoConnections = errors.New("no connections found")

ErrNoConnections may be returned when trying to get the next connection.

Functions

func IsTLSConfigEqual

func IsTLSConfigEqual(c1, c2 *cryptotls.Config) bool

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

type BroadcastStream interface {
	Send(*common.Envelope) error
}

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

func New(config *Config) (*Client, error)

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

func (s *Client) Close()

Close closes all the connections for the client.

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.

func WithAPI

func WithAPI(api string) ConnFilter

WithAPI filters for API.

func WithID

func WithID(id uint32) ConnFilter

WithID filters for ID.

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 ConsensusType

type ConsensusType = string

ConsensusType can be either CFT or BFT.

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

type DeliverConfig struct {
	StartBlkNum int64
	EndBlkNum   uint64
	OutputBlock chan<- *common.Block
}

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

func (s *EnvelopedStream) CreateEnvelope(dataMsg proto.Message) (*common.Envelope, string, error)

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.

Jump to

Keyboard shortcuts

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