gateway

package
v0.0.0-...-f15522e Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCommitHandlers = &list{
	None:       nil,
	OrgAll:     orgAll,
	OrgAny:     orgAny,
	NetworkAll: networkAll,
	NetworkAny: networkAny,
}

DefaultCommitHandlers provides the built-in commit handler implementations.

Functions

This section is empty.

Types

type CommitHandler

type CommitHandler interface {
	StartListening()
	WaitForEvents(int64)
	CancelListening()
}

CommitHandler is currently unimplemented

type CommitHandlerFactory

type CommitHandlerFactory interface {
	Create(string, Network) CommitHandler
}

CommitHandlerFactory is currently unimplemented

type ConfigOption

type ConfigOption = func(*Gateway) error

ConfigOption specifies the gateway configuration source.

func WithConfig

func WithConfig(config core.ConfigProvider) ConfigOption

WithConfig configures the gateway from a network config, such as a ccp file.

func WithSDK

func WithSDK(sdk *fabsdk.FabricSDK) ConfigOption

WithSDK configures the gateway with the configuration from an existing FabricSDK instance

type Contract

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

A Contract object represents a smart contract instance in a network. Applications should get a Contract instance from a Network using the GetContract method

func (*Contract) CreateTransaction

func (c *Contract) CreateTransaction(name string, args ...TransactionOption) (*Transaction, error)

CreateTransaction creates an object representing a specific invocation of a transaction function implemented by this contract, and provides more control over the transaction invocation using the optional arguments. A new transaction object must be created for each transaction invocation.

func (*Contract) EvaluateTransaction

func (c *Contract) EvaluateTransaction(name string, args ...string) ([]byte, error)

EvaluateTransaction will evaluate a transaction function and return its results. The transaction function 'name' will be evaluated on the endorsing peers but the responses will not be sent to the ordering service and hence will not be committed to the ledger. This can be used for querying the world state.

func (*Contract) Name

func (c *Contract) Name() string

Name returns the name of the smart contract

func (*Contract) SubmitTransaction

func (c *Contract) SubmitTransaction(name string, args ...string) ([]byte, error)

SubmitTransaction will submit a transaction to the ledger. The transaction function 'name' will be evaluated on the endorsing peers and then submitted to the ordering service for committing to the ledger.

type Gateway

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

Gateway is the entry point to a Fabric network

func Connect

func Connect(config ConfigOption, identity IdentityOption, options ...Option) (*Gateway, error)

Connect to a gateway defined by a network config file. Must specify a config option, an identity option and zero or more strategy options.

func (*Gateway) Close

func (gw *Gateway) Close()

Close the gateway connection and all associated resources, including removing listeners attached to networks and contracts created by the gateway.

func (*Gateway) GetNetwork

func (gw *Gateway) GetNetwork(name string) (*Network, error)

GetNetwork returns an object representing a network channel.

type Identity

type Identity interface {
	// contains filtered or unexported methods
}

Identity represents a specific identity format

type IdentityOption

type IdentityOption = func(*Gateway) error

IdentityOption specifies the user identity under which all transactions are performed for this gateway instance.

func WithIdentity

func WithIdentity(wallet wallet, label string) IdentityOption

WithIdentity is an optional argument to the Connect method which specifies the identity that is to be used to connect to the network. All operations under this gateway connection will be performed using this identity.

func WithUser

func WithUser(user string) IdentityOption

WithUser is an optional argument to the Connect method which specifies the identity that is to be used to connect to the network. All operations under this gateway connection will be performed using this identity.

type Network

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

A Network object represents the set of peers in a Fabric network (channel). Applications should get a Network instance from a Gateway using the GetNetwork method.

func (*Network) GetContract

func (n *Network) GetContract(chaincodeID string) *Contract

GetContract returns instance of a smart contract on the current network.

func (*Network) Name

func (n *Network) Name() string

Name is the name of the network (also known as channel name)

type Option

type Option = func(*Gateway) error

Option functional arguments can be supplied when connecting to the gateway.

func WithCommitHandler

func WithCommitHandler(handler CommitHandlerFactory) Option

WithCommitHandler is an optional argument to the Connect method which allows an alternative commit handler to be specified. The commit handler defines how client code should wait to receive commit events from peers following submit of a transaction. Currently unimplemented.

func WithDiscovery

func WithDiscovery(discovery bool) Option

WithDiscovery is an optional argument to the Connect method which enables or disables service discovery for all transaction submissions for this gateway.

type Transaction

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

A Transaction represents a specific invocation of a transaction function, and provides flexibility over how that transaction is invoked. Applications should obtain instances of this class from a Contract using the Contract.CreateTransaction method.

Instances of this class are stateful. A new instance <strong>must</strong> be created for each transaction invocation.

func (*Transaction) Evaluate

func (txn *Transaction) Evaluate(args ...string) ([]byte, error)

Evaluate a transaction function and return its results. The transaction function will be evaluated on the endorsing peers but the responses will not be sent to the ordering service and hence will not be committed to the ledger. This can be used for querying the world state.

func (*Transaction) Submit

func (txn *Transaction) Submit(args ...string) ([]byte, error)

Submit a transaction to the ledger. The transaction function represented by this object will be evaluated on the endorsing peers and then submitted to the ordering service for committing to the ledger.

type TransactionOption

type TransactionOption = func(*Transaction) error

TransactionOption functional arguments can be supplied when creating a transaction object

func WithEndorsingPeers

func WithEndorsingPeers(peers ...string) TransactionOption

WithEndorsingPeers is an optional argument to the CreateTransaction method which sets the peers that should be used for endorsement of transaction submitted to the ledger using Submit()

func WithTransient

func WithTransient(data map[string][]byte) TransactionOption

WithTransient is an optional argument to the CreateTransaction method which sets the transient data that will be passed to the transaction function but will not be stored on the ledger. This can be used to pass private data to a transaction function.

type Wallet

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

A Wallet stores identity information used to connect to a Hyperledger Fabric network. Instances are created using factory methods on the implementing objects.

func NewFileSystemWallet

func NewFileSystemWallet(path string) (*Wallet, error)

NewFileSystemWallet creates an instance of a wallet, held in memory. This implementation is not backed by a persistent store.

func NewInMemoryWallet

func NewInMemoryWallet() *Wallet

NewInMemoryWallet creates an instance of a wallet, backed by files on the filesystem

func (*Wallet) Exists

func (w *Wallet) Exists(label string) bool

Exists tests whether the wallet contains an identity for the given label.

func (*Wallet) Get

func (w *Wallet) Get(label string) (Identity, error)

Get an identity from the wallet. The implementation class of the identity object will vary depending on its type.

func (*Wallet) List

func (w *Wallet) List() ([]string, error)

List returns the labels of all identities in the wallet.

func (*Wallet) Put

func (w *Wallet) Put(label string, id Identity) error

Put an identity into the wallet

func (*Wallet) Remove

func (w *Wallet) Remove(label string) error

Remove an identity from the wallet. If the identity does not exist, this method does nothing.

type WalletStore

type WalletStore interface {
	Put(label string, stream []byte) error
	Get(label string) ([]byte, error)
	List() ([]string, error)
	Exists(label string) bool
	Remove(label string) error
}

WalletStore is the interface for implementations that provide backing storage for identities in a wallet. To create create a new backing store, implement all the methods defined in this interface and provide a factory method that wraps an instance of this in a new Wallet object. E.g:

  func NewMyWallet() *Wallet {
	   store := &myWalletStore{ }
	   return &Wallet{store}
  }

type X509Identity

type X509Identity struct {
	Version     int         `json:"version"`
	MspID       string      `json:"mspId"`
	IDType      string      `json:"type"`
	Credentials credentials `json:"credentials"`
}

X509Identity represents an X509 identity

func NewX509Identity

func NewX509Identity(mspid string, cert string, key string) *X509Identity

NewX509Identity creates an X509 identity for storage in a wallet

func (*X509Identity) Certificate

func (x *X509Identity) Certificate() string

Certificate returns the X509 certificate PEM

func (*X509Identity) Key

func (x *X509Identity) Key() string

Key returns the private key PEM

Jump to

Keyboard shortcuts

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