Documentation ¶
Overview ¶
Package ledger enables ledger queries on specified channel on a Fabric network. An application that requires ledger queries from multiple channels should create a separate instance of the ledger client for each channel. Ledger client supports the following queries: QueryInfo, QueryBlock, QueryBlockByHash, QueryBlockByTxID, QueryTransaction and QueryConfig.
Basic Flow: 1) Prepare channel context 2) Create ledger client 3) Query ledger
Index ¶
- type Client
- func (c *Client) QueryBlock(blockNumber uint64, options ...RequestOption) (*common.Block, error)
- func (c *Client) QueryBlockByHash(blockHash []byte, options ...RequestOption) (*common.Block, error)
- func (c *Client) QueryBlockByTxID(txID fab.TransactionID, options ...RequestOption) (*common.Block, error)
- func (c *Client) QueryConfig(options ...RequestOption) (fab.ChannelCfg, error)
- func (c *Client) QueryConfigBlock(options ...RequestOption) (*common.Block, error)
- func (c *Client) QueryInfo(options ...RequestOption) (*fab.BlockchainInfoResponse, error)
- func (c *Client) QueryTransaction(transactionID fab.TransactionID, options ...RequestOption) (*pb.ProcessedTransaction, error)
- type ClientOption
- type RequestOption
- func WithMaxTargets(maxTargets int) RequestOption
- func WithMinTargets(minTargets int) RequestOption
- func WithParentContext(parentContext reqContext.Context) RequestOption
- func WithTargetEndpoints(keys ...string) RequestOption
- func WithTargetFilter(targetFilter fab.TargetFilter) RequestOption
- func WithTargets(targets ...fab.Peer) RequestOption
- func WithTimeout(timeoutType fab.TimeoutType, timeout time.Duration) RequestOption
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 ledger queries on a Fabric network.
func New ¶
func New(channelProvider context.ChannelProvider, opts ...ClientOption) (*Client, error)
New returns a ledger client instance. A ledger client instance provides a handler to query various info on specified channel. An application that requires interaction with multiple channels should create a separate instance of the ledger client for each channel. Ledger client supports specific queries only.
func (*Client) QueryBlock ¶
QueryBlock queries the ledger for Block by block number.
Parameters: blockNumber is required block number(ID) options hold optional request options Returns: block information
func (*Client) QueryBlockByHash ¶
func (c *Client) QueryBlockByHash(blockHash []byte, options ...RequestOption) (*common.Block, error)
QueryBlockByHash queries the ledger for block by block hash.
Parameters: blockHash is required block hash options hold optional request options Returns: block information
func (*Client) QueryBlockByTxID ¶
func (c *Client) QueryBlockByTxID(txID fab.TransactionID, options ...RequestOption) (*common.Block, error)
QueryBlockByTxID queries for block which contains a transaction.
Parameters: txID is required transaction ID options hold optional request options Returns: block information
func (*Client) QueryConfig ¶
func (c *Client) QueryConfig(options ...RequestOption) (fab.ChannelCfg, error)
QueryConfig queries for channel configuration.
Parameters: options hold optional request options Returns: channel configuration information
func (*Client) QueryConfigBlock ¶
func (c *Client) QueryConfigBlock(options ...RequestOption) (*common.Block, error)
QueryConfigBlock returns the current configuration block for the specified channel.
func (*Client) QueryInfo ¶
func (c *Client) QueryInfo(options ...RequestOption) (*fab.BlockchainInfoResponse, error)
QueryInfo queries for various useful blockchain information on this channel such as block height and current block hash.
Parameters: options are optional request options Returns: blockchain information
func (*Client) QueryTransaction ¶
func (c *Client) QueryTransaction(transactionID fab.TransactionID, options ...RequestOption) (*pb.ProcessedTransaction, error)
QueryTransaction queries the ledger for processed transaction by transaction ID.
Parameters: txID is required transaction ID options hold optional request options Returns: processed transaction information
type ClientOption ¶
ClientOption describes a functional parameter for the New constructor
func WithDefaultTargetFilter ¶
func WithDefaultTargetFilter(filter fab.TargetFilter) ClientOption
WithDefaultTargetFilter option to configure new
type RequestOption ¶
RequestOption func for each requestOptions argument
func WithMaxTargets ¶
func WithMaxTargets(maxTargets int) RequestOption
WithMaxTargets specifies maximum number of targets to select per request. Default value for maximum number of targets is 1.
func WithMinTargets ¶
func WithMinTargets(minTargets int) RequestOption
WithMinTargets specifies minimum number of targets that have to respond with no error (or agree on result). Default value for minimum number of targets is 1.
func WithParentContext ¶
func WithParentContext(parentContext reqContext.Context) RequestOption
WithParentContext encapsulates grpc parent context
func WithTargetEndpoints ¶
func WithTargetEndpoints(keys ...string) RequestOption
WithTargetEndpoints allows overriding of the target peers per request. Targets are specified by name or URL, and the SDK will create the underlying peer objects.
func WithTargetFilter ¶
func WithTargetFilter(targetFilter fab.TargetFilter) RequestOption
WithTargetFilter specifies a per-request target peer-filter.
func WithTargets ¶
func WithTargets(targets ...fab.Peer) RequestOption
WithTargets allows for overriding of the target peers per request.
func WithTimeout ¶
func WithTimeout(timeoutType fab.TimeoutType, timeout time.Duration) RequestOption
WithTimeout encapsulates key value pairs of timeout type, timeout duration to Options for QueryInfo, QueryBlock, QueryBlockByHash, QueryBlockByTxID, QueryTransaction, QueryConfig functions