From 70bff28f8a8fd8d334f23b906a89627b7ea71011 Mon Sep 17 00:00:00 2001 From: Yuki Kondo Date: Wed, 5 Jul 2017 20:00:28 -0700 Subject: [PATCH] [FAB-5197]Check all prop-responses in balance-transfer "balance-transfer" app doesn't check all of the proposal responses. An app sends a transaction proposal to multiple peers and get multiple responses. However, the only first response "proposalResponses[0]" is checked repeatedly in the loop. This patch fixes the code to check all of the array value of proposalResponses correctly. Change-Id: Id61e691eb4d1c3a6c4a7a390584dfd74f1fc6196 Signed-off-by: Yuki Kondo --- balance-transfer/app/install-chaincode.js | 4 ++-- balance-transfer/app/instantiate-chaincode.js | 4 ++-- balance-transfer/app/invoke-transaction.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/balance-transfer/app/install-chaincode.js b/balance-transfer/app/install-chaincode.js index 591b4c7ae8..fc408d77c8 100644 --- a/balance-transfer/app/install-chaincode.js +++ b/balance-transfer/app/install-chaincode.js @@ -47,8 +47,8 @@ var installChaincode = function(peers, chaincodeName, chaincodePath, var all_good = true; for (var i in proposalResponses) { let one_good = false; - if (proposalResponses && proposalResponses[0].response && - proposalResponses[0].response.status === 200) { + if (proposalResponses && proposalResponses[i].response && + proposalResponses[i].response.status === 200) { one_good = true; logger.info('install proposal was good'); } else { diff --git a/balance-transfer/app/instantiate-chaincode.js b/balance-transfer/app/instantiate-chaincode.js index 199f139e34..312eb6b60c 100644 --- a/balance-transfer/app/instantiate-chaincode.js +++ b/balance-transfer/app/instantiate-chaincode.js @@ -63,8 +63,8 @@ var instantiateChaincode = function(channelName, chaincodeName, chaincodeVersion var all_good = true; for (var i in proposalResponses) { let one_good = false; - if (proposalResponses && proposalResponses[0].response && - proposalResponses[0].response.status === 200) { + if (proposalResponses && proposalResponses[i].response && + proposalResponses[i].response.status === 200) { one_good = true; logger.info('instantiate proposal was good'); } else { diff --git a/balance-transfer/app/invoke-transaction.js b/balance-transfer/app/invoke-transaction.js index fa4202ddd4..5409808383 100644 --- a/balance-transfer/app/invoke-transaction.js +++ b/balance-transfer/app/invoke-transaction.js @@ -55,8 +55,8 @@ var invokeChaincode = function(peersUrls, channelName, chaincodeName, fcn, args, var all_good = true; for (var i in proposalResponses) { let one_good = false; - if (proposalResponses && proposalResponses[0].response && - proposalResponses[0].response.status === 200) { + if (proposalResponses && proposalResponses[i].response && + proposalResponses[i].response.status === 200) { one_good = true; logger.info('transaction proposal was good'); } else {