Version: v1.0.0-alpha3 Latest Latest

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

Go to latest
Published: Mar 20, 2018 License: Apache-2.0 Imports: 16 Imported by: 0



Package ledger enables ability to query ledger in a Fabric network.



This section is empty.


This section is empty.


This section is empty.


type Client

type Client struct {
	// contains filtered or unexported fields

Client enables ledger queries on a Fabric network.

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 New

func New(channelProvider context.ChannelProvider, opts ...ClientOption) (*Client, error)

New returns a Client instance.

func (*Client) QueryBlock

func (c *Client) QueryBlock(blockNumber uint64, options ...RequestOption) (*common.Block, error)

QueryBlock queries the ledger for Block by block number. This query will be made to specified targets. blockNumber: The number which is the ID of the Block. It returns the block.

func (*Client) QueryBlockByHash

func (c *Client) QueryBlockByHash(blockHash []byte, options ...RequestOption) (*common.Block, error)

QueryBlockByHash queries the ledger for Block by block hash. This query will be made to specified targets. Returns the block.

func (*Client) QueryBlockByTxID

func (c *Client) QueryBlockByTxID(txID fab.TransactionID, options ...RequestOption) (*common.Block, error)

QueryBlockByTxID returns a block which contains a transaction This query will be made to specified targets. Returns the block.

func (*Client) QueryConfig

func (c *Client) QueryConfig(options ...RequestOption) (fab.ChannelCfg, error)

QueryConfig config returns channel configuration

func (*Client) QueryInfo

func (c *Client) QueryInfo(options ...RequestOption) (*fab.BlockchainInfoResponse, error)

QueryInfo queries for various useful information on the state of the channel (height, known peers).

func (*Client) QueryTransaction

func (c *Client) QueryTransaction(transactionID fab.TransactionID, options ...RequestOption) (*pb.ProcessedTransaction, error)

QueryTransaction queries the ledger for Transaction by number. This query will be made to specified targets. Returns the ProcessedTransaction information containing the transaction.

type ClientOption

type ClientOption func(*Client) error

ClientOption describes a functional parameter for the New constructor

func WithDefaultTargetFilter

func WithDefaultTargetFilter(filter fab.TargetFilter) ClientOption

WithDefaultTargetFilter option to configure new

type RequestOption

type RequestOption func(ctx context.Client, opts *requestOptions) error

RequestOption func for each requestOptions argument

func WithMaxTargets

func WithMaxTargets(maxTargets int) RequestOption

WithMaxTargets encapsulates max targets to ledger RequestOption

func WithMinTargets

func WithMinTargets(minTargets int) RequestOption

WithMinTargets encapsulates min targets to ledger RequestOption

func WithParentContext

func WithParentContext(parentContext reqContext.Context) RequestOption

WithParentContext encapsulates grpc context parent to Options

func WithTargetFilter

func WithTargetFilter(targetFilter fab.TargetFilter) RequestOption

WithTargetFilter encapsulates TargetFilter targets to ledger RequestOption

func WithTargetURLs

func WithTargetURLs(urls ...string) RequestOption

WithTargetURLs allows overriding of the target peers for the request. Targets are specified by URL, and the SDK will create the underlying peer objects.

func WithTargets

func WithTargets(targets ...fab.Peer) RequestOption

WithTargets encapsulates fab.Peer targets to ledger RequestOption

func WithTimeout

func WithTimeout(timeoutType core.TimeoutType, timeout time.Duration) RequestOption

WithTimeout encapsulates key value pairs of timeout type, timeout duration to Options for QueryInfo,QueryBlockByHash,QueryBlock,QueryTransaction,QueryConfig functions

Source Files

Jump to

Keyboard shortcuts

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