Skip to content

Commit

Permalink
FABN-844 NodeSDK timeout on queryByChaincode
Browse files Browse the repository at this point in the history
Allow the API queryByChaincode to have a request
timeout setting passed for the this request.

Change-Id: I2e250d30b98c7334bff24e2b0b1c17438968d845
Signed-off-by: Bret Harrison <[email protected]>
  • Loading branch information
harrisob committed Sep 12, 2018
1 parent dfb88eb commit 0f97da3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 15 additions & 9 deletions fabric-client/lib/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3093,14 +3093,20 @@ const Channel = class {
}
/**
* @typedef {Object} ChaincodeQueryRequest
* @property {Peer[]} targets - Optional. The peers that will receive this request,
* when not provided the list of peers added to this channel object will be used.
* @property {string} chaincodeId - Required. The id of the chaincode to process the transaction proposal
* @property {map} transientMap - Optional. <string, byte[]> map that can be used by the chaincode but not
* saved in the ledger, such as cryptographic information for encryption
* @property {string} fcn - Optional. The function name to be returned when calling <code>stub.GetFunctionAndParameters()</code>
* in the target chaincode. Default is 'invoke'
* @property {string[]} args - An array of string arguments specific to the chaincode's 'Invoke' method
* @property {Peer[]} targets - Optional. The peers that will receive this
* request, when not provided the list of peers added to this channel
* object will be used.
* @property {string} chaincodeId - Required. The id of the chaincode to process
* the transaction proposal
* @property {map} transientMap - Optional. <string, byte[]> map that can be
* used by the chaincode but not saved in the ledger, such as cryptographic
* information for encryption
* @property {string} fcn - Optional. The function name to be returned when
* calling <code>stub.GetFunctionAndParameters()</code>
* in the target chaincode. Default is 'invoke'
* @property {string[]} args - An array of string arguments specific to the
* chaincode's 'Invoke' method
* @property {integer} request_timeout - The timeout value to use for this request
*/

/**
Expand Down Expand Up @@ -3147,7 +3153,7 @@ const Channel = class {
signer: signer
};

const results = await Channel.sendTransactionProposal(query_request, this._name, this._clientContext, null);
const results = await Channel.sendTransactionProposal(query_request, this._name, this._clientContext, request.request_timeout);
const responses = results[0];
logger.debug('queryByChaincode - results received');
if (responses && Array.isArray(responses)) {
Expand Down
3 changes: 2 additions & 1 deletion test/integration/e2e/e2eUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,8 @@ function queryChaincode(org, version, targets, fcn, args, value, chaincodeId, t,
chaincodeId : chaincodeId,
txId: tx_id,
fcn: fcn,
args: args
args: args,
request_timeout: 3000
};

// find the peers that match the targets
Expand Down

0 comments on commit 0f97da3

Please sign in to comment.