Skip to content

Commit

Permalink
Refactor near sed make it feasible for adding awk if need be. (#46)
Browse files Browse the repository at this point in the history
Refactor near `sed` make it feasible for adding `awk` if need be.
  • Loading branch information
Montana committed Nov 1, 2023
1 parent ce39ed5 commit 0da0cd3
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ content=$(cat $filename | sed 's|"|\\"|g')
# The workaround is to redirect to a file and cat the contents.
resultfile="${friendlytimestamp}_${TX_ID}_result.txt"
peer chaincode \
invoke \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem \
-n qscc \
-C cl \
-c "{\"function\":\"GetTransactionByID\",\"Args\":[\"cl\", \"${TX_ID}\"]}" > $resultfile 2>&1
invoke \
-o org0-orderer1:6050 \
--tls --cafile /var/hyperledger/fabric/organizations/ordererOrganizations/org0.example.com/msp/tlscacerts/org0-tls-ca.pem \
-n qscc \
-C cl \
-c "{\"function\":\"GetTransactionByID\",\"Args\":[\"cl\", \"${TX_ID}\"]}" >$resultfile 2>&1

status=$(cat $resultfile | grep chaincodeInvokeOrQuery | sed "s|.*result: ||g" | cut -d " " -f 1)
payload=$(cat $resultfile | grep chaincodeInvokeOrQuery | sed "s|.*payload:||g" | base64 -w 0)
Expand All @@ -33,9 +33,8 @@ payload=$(cat $resultfile | grep chaincodeInvokeOrQuery | sed "s|.*payload:||g"
# The protobuf format also contains incompatible escape characters for JSON payloads, so
# this is being returned as a base64-encoded string.

if [ "$payload" == "" ]
then
payload="\"\""
if [ "$payload" == "" ]; then
payload="\"\""
fi

#end=$(date +%s%N)
Expand Down

0 comments on commit 0da0cd3

Please sign in to comment.