fabricclient

package
v0.0.0-...-e171dc0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client enables access to a Fabric network.

func NewClient

func NewClient(config config.Config) *Client

NewClient returns a Client instance.

func (*Client) Channel

func (c *Client) Channel(id string) fab.Channel

Channel returns the channel by ID

func (*Client) Config

func (c *Client) Config() config.Config

Config returns the configuration of the client.

func (*Client) CreateChannel

func (c *Client) CreateChannel(request fab.CreateChannelRequest) (apitxn.TransactionID, error)

CreateChannel ... *

  • Calls the orderer to start building the new channel.
  • Only one of the application instances needs to call this method.
  • Once the channel is successfully created, this and other application
  • instances only need to call Channel joinChannel() to participate on the channel.
  • @param {Object} request - An object containing the following fields:
  • <br>`name` : required - {string} The name of the new channel
  • <br>`orderer` : required - {Orderer} object instance representing the
  • Orderer to send the create request
  • <br>`envelope` : optional - byte[] of the envelope object containing all
  • required settings and signatures to initialize this channel.
  • This envelope would have been created by the command
  • line tool "configtx".
  • <br>`config` : optional - {byte[]} Protobuf ConfigUpdate object extracted from
  • a ConfigEnvelope created by the ConfigTX tool.
  • see extractChannelConfig()
  • <br>`signatures` : optional - {ConfigSignature[]} the list of collected signatures
  • required by the channel create policy when using the `config` parameter.
  • @returns {Result} Result Object with status on the create process.

func (*Client) CryptoSuite

func (c *Client) CryptoSuite() bccsp.BCCSP

CryptoSuite is a convenience method for obtaining the CryptoSuite object in use for this client.

func (*Client) ExtractChannelConfig

func (c *Client) ExtractChannelConfig(configEnvelope []byte) ([]byte, error)

ExtractChannelConfig ... *

  • Extracts the protobuf 'ConfigUpdate' object out of the 'ConfigEnvelope'
  • that is produced by the ConfigTX tool. The returned object may then be
  • signed using the signChannelConfig() method of this class. Once the all
  • signatures have been collected this object and the signatures may be used
  • on the updateChannel or createChannel requests.
  • @param {byte[]} The bytes of the ConfigEnvelope protopuf
  • @returns {byte[]} The bytes of the ConfigUpdate protobuf

func (*Client) InstallChaincode

func (c *Client) InstallChaincode(chaincodeName string, chaincodePath string, chaincodeVersion string,
	chaincodePackage []byte, targets []fab.Peer) ([]*apitxn.TransactionProposalResponse, string, error)

InstallChaincode sends an install proposal to one or more endorsing peers.

func (*Client) LoadUserFromStateStore

func (c *Client) LoadUserFromStateStore(name string) (fab.User, error)

LoadUserFromStateStore ... *

  • Restore the state of this member from the key value store (if found). If not found, do nothing.
  • @returns {Promise} A Promise for a {User} object upon successful restore, or if the user by the name
  • does not exist in the state store, returns null without rejecting the promise

func (*Client) NewChannel

func (c *Client) NewChannel(name string) (fab.Channel, error)

NewChannel returns a channel instance with the given name.

func (*Client) NewTxnID

func (c *Client) NewTxnID() (apitxn.TransactionID, error)

NewTxnID computes a TransactionID for the current user context

func (*Client) QueryChannelInfo

func (c *Client) QueryChannelInfo(name string, peers []fab.Peer) (fab.Channel, error)

QueryChannelInfo ...

  • This is a network call to the designated Peer(s) to discover the channel information.
  • The target Peer(s) must be part of the channel to be able to return the requested information.
  • @param {string} name The name of the channel.
  • @param {[]Peer} peers Array of target Peers to query.
  • @returns {Channel} The channel instance for the name or error if the target Peer(s) does not know
  • anything about the channel.

func (*Client) QueryChannels

func (c *Client) QueryChannels(peer fab.Peer) (*pb.ChannelQueryResponse, error)

QueryChannels queries the names of all the channels that a peer has joined.

func (*Client) QueryInstalledChaincodes

func (c *Client) QueryInstalledChaincodes(peer fab.Peer) (*pb.ChaincodeQueryResponse, error)

QueryInstalledChaincodes queries the installed chaincodes on a peer. Returns the details of all chaincodes installed on a peer.

func (*Client) SaveUserToStateStore

func (c *Client) SaveUserToStateStore(user fab.User, skipPersistence bool) error

SaveUserToStateStore ...

  • Sets an instance of the User class as the security context of this client instance. This user’s credentials (ECert) will be
  • used to conduct transactions and queries with the blockchain network. Upon setting the user context, the SDK saves the object
  • in a persistence cache if the “state store” has been set on the Client instance. If no state store has been set,
  • this cache will not be established and the application is responsible for setting the user context again when the application
  • crashed and is recovered.

func (*Client) SetCryptoSuite

func (c *Client) SetCryptoSuite(cryptoSuite bccsp.BCCSP)

SetCryptoSuite is a convenience method for obtaining the state store object in use for this client.

func (*Client) SetSigningManager

func (c *Client) SetSigningManager(signingMgr fab.SigningManager)

SetSigningManager is a convenience method to set signing manager

func (*Client) SetStateStore

func (c *Client) SetStateStore(stateStore fab.KeyValueStore)

SetStateStore ...

  • The SDK should have a built-in key value store implementation (suggest a file-based implementation to allow easy setup during
  • development). But production systems would want a store backed by database for more robust storage and clustering,
  • so that multiple app instances can share app state via the database (note that this doesn’t necessarily make the app stateful).
  • This API makes this pluggable so that different store implementations can be selected by the application.

func (*Client) SetUserContext

func (c *Client) SetUserContext(user fab.User)

SetUserContext ...

func (*Client) SignChannelConfig

func (c *Client) SignChannelConfig(config []byte) (*common.ConfigSignature, error)

SignChannelConfig ... *

  • Sign a configuration
  • @param {byte[]} config - The Configuration Update in byte form
  • @return {ConfigSignature} - The signature of the current user on the config bytes

func (*Client) SigningManager

func (c *Client) SigningManager() fab.SigningManager

SigningManager returns the signing manager

func (*Client) StateStore

func (c *Client) StateStore() fab.KeyValueStore

StateStore is a convenience method for obtaining the state store object in use for this client.

func (*Client) UserContext

func (c *Client) UserContext() fab.User

UserContext returns the current User.

Directories

Path Synopsis
txnproc
Package txnproc provides functionality for processing fabric transactions.
Package txnproc provides functionality for processing fabric transactions.

Jump to

Keyboard shortcuts

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