client

package
v0.0.0-...-95b87ed Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const DefaultConnectionTimeout = 10 * time.Second

Variables

This section is empty.

Functions

func BroadcastReceive

func BroadcastReceive(broadcast Broadcast, addr string, responses chan common.Status, errs chan error)

func BroadcastSend

func BroadcastSend(broadcast Broadcast, addr string, envelope *common.Envelope) error

func BroadcastWaitForResponse

func BroadcastWaitForResponse(responses chan common.Status, errs chan error) (common.Status, error)

func CreateDeliverEnvelope

func CreateDeliverEnvelope(channelId string, creator []byte, signingIdentity tk.SigningIdentity, cert *tls.Certificate) (*common.Envelope, error)

func CreateEnvelope

func CreateEnvelope(data []byte, header *common.Header, signingIdentity tk.SigningIdentity) (*common.Envelope, error)

func CreateGRPCClient

func CreateGRPCClient(config *ConnectionConfig) (*comm.GRPCClient, error)

func CreateHeader

func CreateHeader(txType common.HeaderType, channelId string, creator []byte, tlsCertHash []byte) (string, *common.Header, error)

func DeliverReceive

func DeliverReceive(df DeliverFiltered, address string, txid string, eventCh chan<- TxEvent) error

func DeliverSend

func DeliverSend(df DeliverFiltered, address string, envelope *common.Envelope) error

func DeliverWaitForResponse

func DeliverWaitForResponse(ctx context.Context, eventCh <-chan TxEvent, txid string) (bool, error)

func GetTLSCertHash

func GetTLSCertHash(cert *tls.Certificate) ([]byte, error)

func GetTransactionID

func GetTransactionID(txEnvelope *common.Envelope) (string, error)

func ValidateClientConfig

func ValidateClientConfig(config ClientConfig) error

Types

type Broadcast

type Broadcast interface {
	Send(m *common.Envelope) error
	Recv() (*ab.BroadcastResponse, error)
	CloseSend() error
}

type Client

type Client struct {
	Config          *ClientConfig
	SigningIdentity tk.SigningIdentity
	Prover          Prover
	TxSubmitter     FabricTxSubmitter
}

func NewClient

func NewClient(config ClientConfig, signingIdentity tk.SigningIdentity) (*Client, error)

func (*Client) Issue

func (c *Client) Issue(tokensToIssue []*token.Token, waitTimeout time.Duration) (*common.Envelope, string, *common.Status, bool, error)

func (*Client) ListTokens

func (c *Client) ListTokens() ([]*token.UnspentToken, error)

func (*Client) Redeem

func (c *Client) Redeem(tokenIDs []*token.TokenId, quantity string, waitTimeout time.Duration) (*common.Envelope, string, *common.Status, bool, error)

func (*Client) Transfer

func (c *Client) Transfer(tokenIDs []*token.TokenId, shares []*token.RecipientShare, waitTimeout time.Duration) (*common.Envelope, string, *common.Status, bool, error)

type ClientConfig

type ClientConfig struct {
	ChannelID     string
	MSPInfo       MSPInfo
	Orderer       ConnectionConfig
	CommitterPeer ConnectionConfig
	ProverPeer    ConnectionConfig
}

func (*ClientConfig) ToJSon

func (config *ClientConfig) ToJSon() ([]byte, error)

type ConnectionConfig

type ConnectionConfig struct {
	Address            string
	ConnectionTimeout  time.Duration
	TLSEnabled         bool
	TLSRootCertFile    string
	ServerNameOverride string
}

type DeliverClient

type DeliverClient interface {
	NewDeliverFiltered(ctx context.Context, opts ...grpc.CallOption) (DeliverFiltered, error)

	Certificate() *tls.Certificate
}

func NewDeliverClient

func NewDeliverClient(config *ConnectionConfig) (DeliverClient, error)

type DeliverFiltered

type DeliverFiltered interface {
	Send(*common.Envelope) error
	Recv() (*pb.DeliverResponse, error)
	CloseSend() error
}

type FabricTxSubmitter

type FabricTxSubmitter interface {
	Submit(txEnvelope *common.Envelope, waitTimeout time.Duration) (*common.Status, bool, error)

	CreateTxEnvelope(tokenTx []byte) (*common.Envelope, string, error)
}

type MSPInfo

type MSPInfo struct {
	MSPConfigPath string
	MSPID         string
	MSPType       string
}

type OrdererClient

type OrdererClient interface {
	NewBroadcast(ctx context.Context, opts ...grpc.CallOption) (Broadcast, error)

	Certificate() *tls.Certificate
}

func NewOrdererClient

func NewOrdererClient(config *ConnectionConfig) (OrdererClient, error)

type Prover

type Prover interface {
	RequestIssue(tokensToIssue []*token.Token, signingIdentity tk.SigningIdentity) ([]byte, error)

	RequestTransfer(tokenIDs []*token.TokenId, shares []*token.RecipientShare, signingIdentity tk.SigningIdentity) ([]byte, error)

	RequestRedeem(tokenIDs []*token.TokenId, quantity string, signingIdentity tk.SigningIdentity) ([]byte, error)

	ListTokens(signingIdentity tk.SigningIdentity) ([]*token.UnspentToken, error)
}

type ProverPeer

type ProverPeer struct {
	ChannelID        string
	ProverPeerClient ProverPeerClient
	RandomnessReader io.Reader
	Time             TimeFunc
}

func NewProverPeer

func NewProverPeer(config *ClientConfig) (*ProverPeer, error)

func (*ProverPeer) CreateSignedCommand

func (prover *ProverPeer) CreateSignedCommand(payload interface{}, signingIdentity tk.SigningIdentity) (*token.SignedCommand, error)

func (*ProverPeer) ListTokens

func (prover *ProverPeer) ListTokens(signingIdentity tk.SigningIdentity) ([]*token.UnspentToken, error)

func (*ProverPeer) RequestIssue

func (prover *ProverPeer) RequestIssue(tokensToIssue []*token.Token, signingIdentity tk.SigningIdentity) ([]byte, error)

func (*ProverPeer) RequestRedeem

func (prover *ProverPeer) RequestRedeem(tokenIDs []*token.TokenId, quantity string, signingIdentity tk.SigningIdentity) ([]byte, error)

func (*ProverPeer) RequestTransfer

func (prover *ProverPeer) RequestTransfer(tokenIDs []*token.TokenId, shares []*token.RecipientShare, signingIdentity tk.SigningIdentity) ([]byte, error)

func (*ProverPeer) SendCommand

func (prover *ProverPeer) SendCommand(ctx context.Context, sc *token.SignedCommand) ([]byte, error)

type ProverPeerClient

type ProverPeerClient interface {
	CreateProverClient() (*grpc.ClientConn, token.ProverClient, error)

	Certificate() *tls.Certificate
}

type ProverPeerClientImpl

type ProverPeerClientImpl struct {
	Address            string
	ServerNameOverride string
	GRPCClient         *comm.GRPCClient
}

func (*ProverPeerClientImpl) Certificate

func (pc *ProverPeerClientImpl) Certificate() *tls.Certificate

func (*ProverPeerClientImpl) CreateProverClient

func (pc *ProverPeerClientImpl) CreateProverClient() (*grpc.ClientConn, token.ProverClient, error)

type Signer

type Signer interface {
	Sign([]byte) ([]byte, error)
}

type SignerIdentity

type SignerIdentity interface {
	Signer

	Serialize() ([]byte, error)
}

type TimeFunc

type TimeFunc func() time.Time

type TxEvent

type TxEvent struct {
	Txid       string
	Committed  bool
	CommitPeer string
	Err        error
}

type TxSubmitter

type TxSubmitter struct {
	Config          *ClientConfig
	SigningIdentity tk.SigningIdentity
	Creator         []byte
	OrdererClient   OrdererClient
	DeliverClient   DeliverClient
}

func NewTxSubmitter

func NewTxSubmitter(config *ClientConfig, signingIdentity tk.SigningIdentity) (*TxSubmitter, error)

func (*TxSubmitter) CreateTxEnvelope

func (s *TxSubmitter) CreateTxEnvelope(txBytes []byte) (*common.Envelope, string, error)

func (*TxSubmitter) Submit

func (s *TxSubmitter) Submit(txEnvelope *common.Envelope, waitTimeout time.Duration) (*common.Status, bool, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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