mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
[FAB-12587] Fix for Query Block by block hash API
Block Query by hash Fixed in balance transfer app.
Change-Id: Iad5c0af657e7359ee787e1f939a6695d470da1cd
Signed-off-by: sebastianpaulp <spaul@jeadigital.com>
(cherry picked from commit 6dc5ce503b)
This commit is contained in:
parent
7fd95f6a25
commit
f2b2ebf40a
2 changed files with 17 additions and 18 deletions
|
|
@ -115,7 +115,7 @@ var getBlockByHash = async function(peer, channelName, hash, username, org_name)
|
|||
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) {
|
||||
logger.debug(response_payload);
|
||||
return response_payload;
|
||||
|
|
|
|||
|
|
@ -209,11 +209,13 @@ echo
|
|||
|
||||
echo "GET query Block by blockNumber"
|
||||
echo
|
||||
curl -s -X GET \
|
||||
BLOCK_INFO=$(curl -s -X GET \
|
||||
"http://localhost:4000/channels/mychannel/blocks/1?peer=peer0.org1.example.com" \
|
||||
-H "authorization: Bearer $ORG1_TOKEN" \
|
||||
-H "content-type: application/json"
|
||||
echo
|
||||
-H "content-type: application/json")
|
||||
echo $BLOCK_INFO
|
||||
# Assign previvious block hash to HASH
|
||||
HASH=$(echo $BLOCK_INFO | jq -r ".header.previous_hash")
|
||||
echo
|
||||
|
||||
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
|
||||
|
||||
############################################################################
|
||||
### TODO: What to pass to fetch the Block information
|
||||
############################################################################
|
||||
#echo "GET query Block by Hash"
|
||||
#echo
|
||||
#hash=????
|
||||
#curl -s -X GET \
|
||||
# "http://localhost:4000/channels/mychannel/blocks?hash=$hash&peer=peer1" \
|
||||
# -H "authorization: Bearer $ORG1_TOKEN" \
|
||||
# -H "cache-control: no-cache" \
|
||||
# -H "content-type: application/json" \
|
||||
# -H "x-access-token: $ORG1_TOKEN"
|
||||
#echo
|
||||
#echo
|
||||
|
||||
echo "GET query Block by Hash - Hash is $HASH"
|
||||
echo
|
||||
curl -s -X GET \
|
||||
"http://localhost:4000/channels/mychannel/blocks?hash=$HASH&peer=peer0.org1.example.com" \
|
||||
-H "authorization: Bearer $ORG1_TOKEN" \
|
||||
-H "cache-control: no-cache" \
|
||||
-H "content-type: application/json" \
|
||||
-H "x-access-token: $ORG1_TOKEN"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "GET query ChainInfo"
|
||||
echo
|
||||
|
|
|
|||
Loading…
Reference in a new issue