@@ -331,7 +331,11 @@ func resolveOrdererURL(ordererURL string) string {
331331// (height, known peers).
332332// This query will be made to the primary peer.
333333func (c * Channel ) QueryInfo () (* common.BlockchainInfo , error ) {
334- l := NewLedger (c .clientContext , c .name )
334+ l , err := NewLedger (c .clientContext , c .name )
335+ if err != nil {
336+ return nil , errors .WithMessage (err , "ledger client creation failed" )
337+ }
338+
335339 resps , err := l .QueryInfo ([]fab.ProposalProcessor {c .PrimaryPeer ()})
336340 if err != nil {
337341 return nil , err
@@ -343,7 +347,11 @@ func (c *Channel) QueryInfo() (*common.BlockchainInfo, error) {
343347// This query will be made to the primary peer.
344348// Returns the block.
345349func (c * Channel ) QueryBlockByHash (blockHash []byte ) (* common.Block , error ) {
346- l := NewLedger (c .clientContext , c .name )
350+ l , err := NewLedger (c .clientContext , c .name )
351+ if err != nil {
352+ return nil , errors .WithMessage (err , "ledger client creation failed" )
353+ }
354+
347355 resps , err := l .QueryBlockByHash (blockHash , []fab.ProposalProcessor {c .PrimaryPeer ()})
348356 if err != nil {
349357 return nil , err
@@ -356,7 +364,11 @@ func (c *Channel) QueryBlockByHash(blockHash []byte) (*common.Block, error) {
356364// blockNumber: The number which is the ID of the Block.
357365// It returns the block.
358366func (c * Channel ) QueryBlock (blockNumber int ) (* common.Block , error ) {
359- l := NewLedger (c .clientContext , c .name )
367+ l , err := NewLedger (c .clientContext , c .name )
368+ if err != nil {
369+ return nil , errors .WithMessage (err , "ledger client creation failed" )
370+ }
371+
360372 resps , err := l .QueryBlock (blockNumber , []fab.ProposalProcessor {c .PrimaryPeer ()})
361373 if err != nil {
362374 return nil , err
@@ -369,7 +381,11 @@ func (c *Channel) QueryBlock(blockNumber int) (*common.Block, error) {
369381// Returns the ProcessedTransaction information containing the transaction.
370382// TODO: add optional target
371383func (c * Channel ) QueryTransaction (transactionID string ) (* pb.ProcessedTransaction , error ) {
372- l := NewLedger (c .clientContext , c .name )
384+ l , err := NewLedger (c .clientContext , c .name )
385+ if err != nil {
386+ return nil , errors .WithMessage (err , "ledger client creation failed" )
387+ }
388+
373389 resps , err := l .QueryTransaction (transactionID , []fab.ProposalProcessor {c .PrimaryPeer ()})
374390 if err != nil {
375391 return nil , err
@@ -380,7 +396,11 @@ func (c *Channel) QueryTransaction(transactionID string) (*pb.ProcessedTransacti
380396// QueryInstantiatedChaincodes queries the instantiated chaincodes on this channel.
381397// This query will be made to the primary peer.
382398func (c * Channel ) QueryInstantiatedChaincodes () (* pb.ChaincodeQueryResponse , error ) {
383- l := NewLedger (c .clientContext , c .name )
399+ l , err := NewLedger (c .clientContext , c .name )
400+ if err != nil {
401+ return nil , errors .WithMessage (err , "ledger client creation failed" )
402+ }
403+
384404 resps , err := l .QueryInstantiatedChaincodes ([]fab.ProposalProcessor {c .PrimaryPeer ()})
385405 if err != nil {
386406 return nil , err
@@ -392,7 +412,11 @@ func (c *Channel) QueryInstantiatedChaincodes() (*pb.ChaincodeQueryResponse, err
392412// QueryConfigBlock returns the current configuration block for the specified channel. If the
393413// peer doesn't belong to the channel, return error
394414func (c * Channel ) QueryConfigBlock (peers []fab.Peer , minResponses int ) (* common.ConfigEnvelope , error ) {
395- l := NewLedger (c .clientContext , c .name )
415+ l , err := NewLedger (c .clientContext , c .name )
416+ if err != nil {
417+ return nil , errors .WithMessage (err , "ledger client creation failed" )
418+ }
419+
396420 return l .QueryConfigBlock (peers , minResponses )
397421}
398422
0 commit comments