Get block by hash Fixed

changes
1.
file path
fabric-samples/### balance-transfer/app/query.js
L 118
let response_payload = await channel.queryBlockByHash(Buffer.from(hash,'hex'), peer);

file path
fabric-samples/### balance-transfer/testAPIs.sh
Assigned block info to variable BLOCK_INFO, assign previous block hash to variable HASH and pass it to query block by hash endpoint

Signed-off-by: sebastianpaulp <spaul@jeadigital.com>
This commit is contained in:
sebastianpaulp 2018-10-24 17:00:36 +05:30
parent 7fd95f6a25
commit 1879483ff8
2 changed files with 17 additions and 18 deletions

View file

@ -115,7 +115,7 @@ var getBlockByHash = async function(peer, channelName, hash, username, org_name)
throw new Error(message); throw new Error(message);
} }
let response_payload = await channel.queryBlockByHash(Buffer.from(hash), peer); let response_payload = await channel.queryBlockByHash(Buffer.from(hash,'hex'), peer);
if (response_payload) { if (response_payload) {
logger.debug(response_payload); logger.debug(response_payload);
return response_payload; return response_payload;

View file

@ -209,11 +209,13 @@ echo
echo "GET query Block by blockNumber" echo "GET query Block by blockNumber"
echo echo
curl -s -X GET \ BLOCK_INFO=$(curl -s -X GET \
"http://localhost:4000/channels/mychannel/blocks/1?peer=peer0.org1.example.com" \ "http://localhost:4000/channels/mychannel/blocks/1?peer=peer0.org1.example.com" \
-H "authorization: Bearer $ORG1_TOKEN" \ -H "authorization: Bearer $ORG1_TOKEN" \
-H "content-type: application/json" -H "content-type: application/json")
echo echo $BLOCK_INFO
# Assign previvious block hash to HASH
HASH=$(echo $BLOCK_INFO | jq ".header.previous_hash" | sed "s/\"//g")
echo echo
echo "GET query Transaction by TransactionID" echo "GET query Transaction by TransactionID"
@ -224,20 +226,17 @@ curl -s -X GET http://localhost:4000/channels/mychannel/transactions/$TRX_ID?pee
echo echo
echo echo
############################################################################
### TODO: What to pass to fetch the Block information echo "GET query Block by Hash | Hash is $HASH"
############################################################################ echo
#echo "GET query Block by Hash" curl -s -X GET \
#echo "http://localhost:4000/channels/mychannel/blocks?hash=$HASH&peer=peer0.org1.example.com" \
#hash=???? -H "authorization: Bearer $ORG1_TOKEN" \
#curl -s -X GET \ -H "cache-control: no-cache" \
# "http://localhost:4000/channels/mychannel/blocks?hash=$hash&peer=peer1" \ -H "content-type: application/json" \
# -H "authorization: Bearer $ORG1_TOKEN" \ -H "x-access-token: $ORG1_TOKEN"
# -H "cache-control: no-cache" \ echo
# -H "content-type: application/json" \ echo
# -H "x-access-token: $ORG1_TOKEN"
#echo
#echo
echo "GET query ChainInfo" echo "GET query ChainInfo"
echo echo