client

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package client connects to the Fabric-X orderer. It combines the user identity and client-TLS material (user.Config) with the orderer connection information read from a config block (ordererconn.Info) to sign and send seek and broadcast envelopes to assemblers and routers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadConfigBlock

func ReadConfigBlock(path string) (*cb.Block, error)

ReadConfigBlock reads and unmarshals a protobuf config block from path. It is shared by the commands that take a --current-block file.

func SequenceFromBlock

func SequenceFromBlock(block *cb.Block) (uint64, error)

SequenceFromBlock returns the config sequence recorded in a config block's configuration envelope. It reads the sequence field directly rather than building a channel config bundle, so it needs no BCCSP.

func WriteBlock

func WriteBlock(block *cb.Block, path string) error

WriteBlock marshals block and writes it to path.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client sends signed seek and broadcast envelopes to the orderer using the user identity for signing and TLS.

func LoadFromFiles

func LoadFromFiles(configPath, blockPath string, csp bccsp.BCCSP) (*Client, error)

LoadFromFiles builds a Client from the user configuration YAML at configPath and the config block at blockPath, using csp to build the channel config bundle.

func LoadWithConnInfo

func LoadWithConnInfo(config *user.Config, info *ordererconn.Info) (*Client, error)

LoadWithConnInfo builds a Client that dials the orderer described by info, signing with the identity in config.

func (*Client) AssemblerEndpoints

func (c *Client) AssemblerEndpoints() []string

AssemblerEndpoints returns the assembler endpoints the client targets, in config-block order.

func (*Client) BroadcastToAllRouters

func (c *Client) BroadcastToAllRouters(envelope *cb.Envelope) ([]RouterStatus, error)

BroadcastToAllRouters sends a prepared envelope to every router and returns one RouterStatus per router, in endpoint order, reporting whether each router acknowledged the envelope. The envelope must already be built and signed by the caller (e.g. a prepared configuration transaction). It returns an error only when no routers are configured; individual router rejections and unreachable routers are carried in the returned statuses.

func (*Client) ChannelID

func (c *Client) ChannelID() string

ChannelID returns the channel the client targets.

func (*Client) FaultThreshold

func (c *Client) FaultThreshold() int

FaultThreshold returns f, the number of faulty parties the network tolerates, derived from the number of parties: f = (n-1)/3.

func (*Client) FetchBlock

func (c *Client) FetchBlock(seek *ab.SeekInfo) (*cb.Block, error)

FetchBlock seeks the block described by seek from the first reachable assembler, failing over to the next assembler on error.

func (*Client) FetchLedgerStatus

func (c *Client) FetchLedgerStatus(ctx context.Context, endpoint string) (LedgerStatus, error)

FetchLedgerStatus returns the ledger status of a single assembler. It seeks the assembler's newest block (whose number is the ledger's last block), follows its last-config index to the config block, and reads that block's sequence. Unlike FetchBlock, it targets one endpoint and does not fail over, so callers (e.g. `fxadmin follow`) can track each assembler's ledger independently. ctx bounds the whole operation, including both underlying block fetches.

func (*Client) NumParties

func (c *Client) NumParties() int

NumParties returns the number of parties in the network the client targets, as read from the config block's ARMA shared config.

type LedgerStatus

type LedgerStatus struct {
	LastBlockNumber    uint64
	LastConfigSequence uint64
	ConfigBlock        *cb.Block
}

LedgerStatus summarizes a single assembler's ledger: the number of its newest block (its height indicator), the config sequence of its last config block, and the last config block itself.

type RouterStatus

type RouterStatus struct {
	Endpoint string
	Err      error
}

RouterStatus is the outcome of broadcasting an envelope to a single router. Err is nil when the router acknowledged the envelope with status SUCCESS, and otherwise describes the rejection or the reason the router was unreachable.

Directories

Path Synopsis
Package test provides in-process AtomicBroadcast servers for testing the broadcast of envelopes to Fabric-X routers.
Package test provides in-process AtomicBroadcast servers for testing the broadcast of envelopes to Fabric-X routers.

Jump to

Keyboard shortcuts

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