This repository was archived by the owner on Apr 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +9
-14
lines changed
Expand file tree Collapse file tree 4 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ const logger = require('./logger').getLogger('Gateway');
3636 * @memberof module:fabric-network
3737 * @property {number } [commitTimeout = 300] The timeout period in seconds to wait for commit notification to
3838 * complete.
39+ * @property {number } [endorseTimeout = 45] The timeout period in seconds to wait
40+ * for the endorsement to complete.
3941 * @property {?module:fabric-network.Gateway~TxEventHandlerFactory } [strategy=MSPID_SCOPE_ALLFORTX] Event handling strategy to identify
4042 * successful transaction commits. A null value indicates that no event handling is desired. The default is
4143 * [MSPID_SCOPE_ALLFORTX]{@link module:fabric-network.DefaultEventHandlerStrategies}.
@@ -154,6 +156,7 @@ class Gateway {
154156 } ,
155157 eventHandlerOptions : {
156158 commitTimeout : 300 , // 5 minutes
159+ endorseTimeout : 45 , // Same as "request-timeout" default value in fabric-client/config/default.json
157160 strategy : EventStrategies . MSPID_SCOPE_ALLFORTX
158161 } ,
159162 discovery : {
Original file line number Diff line number Diff line change @@ -175,14 +175,11 @@ class Transaction {
175175 }
176176 request . endorsement_hint = { chaincodes : this . _contract . getDiscoveryInterests ( ) } ;
177177
178- const commitTimeout = options . commitTimeout * 1000 ; // in ms
179- let timeout = this . _contract . gateway . getClient ( ) . getConfigSetting ( 'request-timeout' , commitTimeout ) ;
180- if ( timeout < commitTimeout ) {
181- timeout = commitTimeout ;
182- }
178+ // Same as v2.2, define the endorseTimeout property which is used as the timeout for endorsement of the proposal
179+ const endorseTimeout = options . endorseTimeout * 1000 ; // in ms
183180
184181 // node sdk will target all peers on the channel that are endorsingPeer or do something special for a discovery environment
185- const results = await channel . sendTransactionProposal ( request , timeout ) ;
182+ const results = await channel . sendTransactionProposal ( request , endorseTimeout ) ;
186183 const proposalResponses = results [ 0 ] ;
187184 const proposal = results [ 1 ] ;
188185
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ describe('Network', () => {
9292 } ,
9393 eventHandlerOptions : {
9494 commitTimeout : 300 ,
95+ endorseTimeout : 45 ,
9596 strategy : EventStrategies . MSPID_SCOPE_ALLFORTX
9697 } ,
9798 queryHandlerOptions : {
Original file line number Diff line number Diff line change @@ -300,18 +300,12 @@ describe('Transaction', () => {
300300 return expect ( promise ) . to . be . rejectedWith ( 'Transaction has already been invoked' ) ;
301301 } ) ;
302302
303- it ( 'sends proposal with long timeout' , async ( ) => {
304- stubContract . getEventHandlerOptions . returns ( { commitTimeout : 999 } ) ;
303+ it ( 'uses endorseTimeout option as proposal timeout' , async ( ) => {
304+ stubContract . getEventHandlerOptions . returns ( { endorseTimeout : 999 } ) ;
305305 await transaction . submit ( ) ;
306306 sinon . assert . calledWith ( channel . sendTransactionProposal , sinon . match ( expectedProposal ) , 999000 ) ;
307307 } ) ;
308308
309- it ( 'sends proposal with short timeout' , async ( ) => {
310- stubContract . getEventHandlerOptions . returns ( { commitTimeout : 3 } ) ;
311- await transaction . submit ( ) ;
312- sinon . assert . calledWith ( channel . sendTransactionProposal , sinon . match ( expectedProposal ) , 45000 ) ;
313- } ) ;
314-
315309 it ( 'sends proposal to specified peers' , async ( ) => {
316310 const peer = sinon . createStubInstance ( ChannelPeer ) ;
317311 const endorsingPeers = [ peer ] ;
You can’t perform that action at this time.
0 commit comments