client

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrEmptyConfig         = errors.Error(`empty config`)
	ErrInvalidPEMStructure = errors.Error(`invalid PEM structure`)

	ErrNoPeersForMSP = errors.Error(`no peers for MSP`)
	ErrMSPNotFound   = errors.Error(`MSP not found`)
	ErrPeerNotReady  = errors.Error(`peer not ready`)
)
View Source
const (
	// FnShowMaxLength limit to show fn name (args[0]) in debug and error messages
	FnShowMaxLength = 100

	PeerDefaultDialTimeout    = 5 * time.Second
	PeerDefaultEndorseTimeout = 5 * time.Second
)
View Source
const (
	OrdererDefaultDialTimeout = 5 * time.Second
)

Variables

View Source
var (
	ErrEmptyMSPConfig              = errors.New(`empty MSP config`)
	ErrDiscoveryConnectionRequired = errors.New(`discovery connection required`)
	ErrDiscoverySignerRequired     = errors.New(`discovery signer required`)
)
View Source
var DefaultLogger, _ = zap.NewDevelopment()
View Source
var ErrEndorsingMSPsRequired = errors.New(`endorsing MSPs required`)

Functions

func NewChannel added in v0.7.4

func NewChannel(
	mspId, chanName string,
	peerPool api.PeerPool,
	orderer api.Orderer,
	dp api.DiscoveryProvider,
	identity msp.SigningIdentity,
	fabricV2 bool,
	log *zap.Logger,
) api.Channel

func NewFromGRPC added in v0.7.4

func NewFromGRPC(conn *grpc.ClientConn, identity msp.SigningIdentity, tlsCertHash []byte, logger *zap.Logger, endorseDefaultTimeout time.Duration) (api.Peer, error)

NewFromGRPC allows initializing peer from existing GRPC connection

func NewPeer added in v0.7.4

func NewPeer(ctx context.Context, c config.ConnectionConfig, identity msp.SigningIdentity, logger *zap.Logger) (api.Peer, error)

NewPeer returns new peer instance based on peer config

func StrategyGRPC added in v0.10.0

func StrategyGRPC(d time.Duration) api.PeerPoolCheckStrategy

Types

type Channel added in v0.7.4

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

func (*Channel) Chaincode added in v0.7.4

func (c *Channel) Chaincode(serviceDiscCtx context.Context, ccName string) (api.Chaincode, error)

Chaincode - returns interface with actions over chaincode ctx is necessary for service discovery

func (*Channel) Join added in v0.7.4

func (c *Channel) Join(ctx context.Context) error

type Client added in v0.10.0

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

func New added in v0.7.4

func New(ctx context.Context, opts ...Opt) (*Client, error)

func (*Client) Blocks added in v0.10.0

func (c *Client) Blocks(
	ctx context.Context,
	channel string,
	identity msp.SigningIdentity,
	blockRange ...int64,
) (<-chan *common.Block, func() error, error)

func (*Client) Channel added in v0.10.0

func (c *Client) Channel(name string) api.Channel

func (*Client) CryptoSuite added in v0.10.0

func (c *Client) CryptoSuite() crypto.Suite

func (*Client) CurrentIdentity added in v0.10.0

func (c *Client) CurrentIdentity() msp.SigningIdentity

func (*Client) CurrentMspPeers added in v0.10.0

func (c *Client) CurrentMspPeers() []api.Peer

func (*Client) Events added in v0.10.0

func (c *Client) Events(
	ctx context.Context,
	channel string,
	chaincode string,
	identity msp.SigningIdentity,
	blockRange ...int64,
) (events chan interface {
	Event() *fabPeer.ChaincodeEvent
	Block() uint64
	TxTimestamp() *timestamp.Timestamp
}, closer func() error, err error)

func (*Client) FabricV2 added in v0.10.0

func (c *Client) FabricV2() bool

func (*Client) Invoke added in v0.10.0

func (c *Client) Invoke(
	ctx context.Context,
	channel string,
	ccName string,
	args [][]byte,
	signer msp.SigningIdentity,
	transient map[string][]byte,
	txWaiterType string,
) (*fabPeer.Response, string, error)

func (*Client) ParsedBlocks added in v0.10.6

func (c *Client) ParsedBlocks(
	ctx context.Context,
	channel string,
	identity msp.SigningIdentity,
	blockRange ...int64,
) (<-chan *block.Block, func() error, error)

func (*Client) PeerPool added in v0.10.0

func (c *Client) PeerPool() api.PeerPool

func (*Client) Query added in v0.10.0

func (c *Client) Query(
	ctx context.Context,
	channel string,
	chaincode string,
	args [][]byte,
	identity msp.SigningIdentity,
	transient map[string][]byte,
) (*fabPeer.Response, error)

type ErrUnexpectedStatus added in v0.7.4

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

func (*ErrUnexpectedStatus) Error added in v0.7.4

func (e *ErrUnexpectedStatus) Error() string

type Opt added in v0.10.0

type Opt func(c *Client) error

Opt describes opt which will be applied to coreOptions

func WithConfigRaw

func WithConfigRaw(config config.Config) Opt

WithConfigRaw allows passing to Client created config instance

func WithConfigYaml

func WithConfigYaml(configPath string) Opt

WithConfigYaml allows passing path to YAML configuration file

func WithCrypto added in v0.6.3

func WithCrypto(crypto crypto.Suite) Opt

WithCrypto allows to init Client crypto suite.

func WithDefaultSigner added in v0.10.0

func WithDefaultSigner(signer msp.SigningIdentity) Opt

func WithDiscoverySigner added in v0.10.0

func WithDiscoverySigner(signer msp.SigningIdentity) Opt

func WithFabricV2 added in v0.6.3

func WithFabricV2(fabricV2 bool) Opt

WithFabricV2 toggles Client to use fabric version 2.

func WithLogger

func WithLogger(log *zap.Logger) Opt

WithLogger allows to pass custom copy of zap.Logger insteadof logger.DefaultLogger

func WithOrderer

func WithOrderer(orderer api.Orderer) Opt

WithOrderer allows using custom instance of orderer in Client

func WithPeerPool

func WithPeerPool(pool api.PeerPool) Opt

WithPeerPool allows adding custom peer pool

func WithPeers added in v0.6.3

func WithPeers(mspID string, peers []config.ConnectionConfig) Opt

WithPeers allows to init Client with peers for specified mspID.

func WithSigner added in v0.10.0

func WithSigner(signer msp.SigningIdentity) Opt

type Orderer added in v0.7.4

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

func NewOrderer added in v0.7.4

func NewOrderer(dialCtx context.Context, c config.ConnectionConfig, logger *zap.Logger) (*Orderer, error)

func NewOrdererFromGRPC added in v0.7.4

func NewOrdererFromGRPC(conn *grpc.ClientConn) (*Orderer, error)

NewOrdererFromGRPC allows initializing orderer from existing GRPC connection

func (*Orderer) Broadcast added in v0.7.4

func (o *Orderer) Broadcast(ctx context.Context, envelope *common.Envelope) (resp *fabricOrderer.BroadcastResponse, err error)

func (*Orderer) Deliver added in v0.7.4

func (o *Orderer) Deliver(ctx context.Context, envelope *common.Envelope) (block *common.Block, err error)

func (*Orderer) GetConfigBlock added in v0.7.4

func (o *Orderer) GetConfigBlock(ctx context.Context, signer msp.SigningIdentity, channelName string) (*common.Block, error)

GetConfigBlock returns config block by channel name

type PeerPool added in v0.7.4

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

func NewPeerPool added in v0.7.4

func NewPeerPool(ctx context.Context, log *zap.Logger) *PeerPool

func (*PeerPool) Add added in v0.7.4

func (p *PeerPool) Add(mspId string, peer api.Peer, peerChecker api.PeerPoolCheckStrategy) error

func (*PeerPool) Close added in v0.7.4

func (p *PeerPool) Close() error

func (*PeerPool) DeliverClient added in v0.7.4

func (p *PeerPool) DeliverClient(mspId string, identity msp.SigningIdentity) (api.DeliverClient, error)

func (*PeerPool) EndorseOnMSP added in v0.7.4

func (p *PeerPool) EndorseOnMSP(ctx context.Context, mspID string, proposal *peerproto.SignedProposal) (*peerproto.ProposalResponse, error)

EndorseOnMSP finds first ready peer in pool for specified mspId , endorses proposal and returns proposal response - no load balancing between msp peers - no data is not sent to the orderer

func (*PeerPool) EndorseOnMSPs added in v0.7.4

func (p *PeerPool) EndorseOnMSPs(ctx context.Context, mspIDs []string, proposal *peerproto.SignedProposal) ([]*peerproto.ProposalResponse, error)

func (*PeerPool) FirstReadyPeer added in v0.7.4

func (p *PeerPool) FirstReadyPeer(mspId string) (api.Peer, error)

func (*PeerPool) GetMSPPeers added in v0.7.4

func (p *PeerPool) GetMSPPeers(mspID string) []api.Peer

func (*PeerPool) GetPeers added in v0.7.4

func (p *PeerPool) GetPeers() map[string][]api.Peer

Directories

Path Synopsis
ca

Jump to

Keyboard shortcuts

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