Ledger is a client that provides access to the underlying ledger of a channel.
type Ledger struct {
// contains filtered or unexported fields
}
func NewLedger(chName string) (*Ledger, error)
NewLedger constructs a Ledger client for the current context and named channel.
func (c *Ledger) QueryBlock(reqCtx reqContext.Context, blockNumber uint64, targets []fab.ProposalProcessor, verifier ResponseVerifier) ([]*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 (c *Ledger) QueryBlockByHash(reqCtx reqContext.Context, blockHash []byte, targets []fab.ProposalProcessor, verifier ResponseVerifier) ([]*common.Block, error)
QueryBlockByHash queries the ledger for Block by block hash. This query will be made to specified targets. Returns the block.
func (c *Ledger) QueryBlockByTxID(reqCtx reqContext.Context, txID fab.TransactionID, targets []fab.ProposalProcessor, verifier ResponseVerifier) ([]*common.Block, error)
QueryBlockByTxID returns a block which contains a transaction This query will be made to specified targets. Returns the block.
func (c *Ledger) QueryCollectionsConfig(reqCtx reqContext.Context, chaincodeName string, targets []fab.ProposalProcessor, verifier ResponseVerifier) ([]*common.CollectionConfigPackage, error)
QueryCollectionsConfig queries the collections config for a chaincode on this channel.
func (c *Ledger) QueryConfigBlock(reqCtx reqContext.Context, targets []fab.ProposalProcessor, verifier ResponseVerifier) (*common.Block, error)
QueryConfigBlock returns the current configuration block for the specified channel. If the peer doesn't belong to the channel, return error
func (c *Ledger) QueryInfo(reqCtx reqContext.Context, targets []fab.ProposalProcessor, verifier ResponseVerifier) ([]*fab.BlockchainInfoResponse, error)
QueryInfo queries for various useful information on the state of the channel (height, known peers).
func (c *Ledger) QueryInstantiatedChaincodes(reqCtx reqContext.Context, targets []fab.ProposalProcessor, verifier ResponseVerifier) ([]*pb.ChaincodeQueryResponse, error)
QueryInstantiatedChaincodes queries the instantiated chaincodes on this channel. This query will be made to specified targets.
func (c *Ledger) QueryTransaction(reqCtx reqContext.Context, transactionID fab.TransactionID, targets []fab.ProposalProcessor, verifier ResponseVerifier) ([]*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.
ResponseVerifier checks transaction proposal response(s)
type ResponseVerifier interface { Verify(response *fab.TransactionProposalResponse) error Match(response []*fab.TransactionProposalResponse) error }
TransactionProposalResponseVerifier struct is for verifying TransactionProposalResponse and matches config blocks
type TransactionProposalResponseVerifier struct { MinResponses int }
func (tprv *TransactionProposalResponseVerifier) Match(transactionProposalResponses []*fab.TransactionProposalResponse) error
Match verifies and matches transaction proposal responses
func (tprv *TransactionProposalResponseVerifier) Verify(response *fab.TransactionProposalResponse) error
Verify checks transaction proposal response (empty)
Transactor enables sending transactions and transaction proposals on the channel.
type Transactor struct { ChannelID string // contains filtered or unexported fields }
func NewTransactor(reqCtx reqContext.Context, cfg fab.ChannelCfg) (*Transactor, error)
NewTransactor returns a Transactor for the current context and channel config.
func (t *Transactor) CreateTransaction(request fab.TransactionRequest) (*fab.Transaction, error)
CreateTransaction create a transaction with proposal response. TODO: should this be removed as it is purely a wrapper?
func (t *Transactor) CreateTransactionHeader(opts ...fab.TxnHeaderOpt) (fab.TransactionHeader, error)
CreateTransactionHeader creates a Transaction Header based on the current context.
func (t *Transactor) SendTransaction(tx *fab.Transaction) (*fab.TransactionResponse, error)
SendTransaction send a transaction to the chain’s orderer service (one or more orderer endpoints) for consensus and committing to the ledger.
func (t *Transactor) SendTransactionProposal(proposal *fab.TransactionProposal, targets []fab.ProposalProcessor) ([]*fab.TransactionProposalResponse, error)
SendTransactionProposal sends a TransactionProposal to the target peers.
Name | Synopsis |
---|---|
.. | |
membership |