Commit 6026a7f7 authored by liuyuhang's avatar liuyuhang

modify query tx bug

parent 8a46338e
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# shellcheck disable=SC2128 # shellcheck disable=SC2128
set +e set +e
set -o pipefail set -o pipefail
set -x
MAIN_HTTP="" MAIN_HTTP=""
CASE_ERR="" CASE_ERR=""
...@@ -63,11 +62,12 @@ chain33_GetAccounts() { ...@@ -63,11 +62,12 @@ chain33_GetAccounts() {
function query_tx() { function query_tx() {
block_wait 1 block_wait 1
local txhash="$1" local txhash="$1"
local http="$2"
local req='"method":"Chain33.QueryTransaction","params":[{"hash":"'"$txhash"'"}]' local req='"method":"Chain33.QueryTransaction","params":[{"hash":"'"$txhash"'"}]'
echo "req=$req" echo "req=$req"
local times=10 local times=10
while true; do while true; do
ret=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result.tx.hash") ret=$(curl -ksd "{$req}" "${http}" | jq -r ".result.tx.hash")
echo "====query tx= ${1}, return=$ret " echo "====query tx= ${1}, return=$ret "
if [ "${ret}" != "${1}" ]; then if [ "${ret}" != "${1}" ]; then
block_wait 1 block_wait 1
...@@ -75,7 +75,7 @@ function query_tx() { ...@@ -75,7 +75,7 @@ function query_tx() {
if [ $times -le 0 ]; then if [ $times -le 0 ]; then
echo "====query tx=$1 failed" echo "====query tx=$1 failed"
echo "req=$req" echo "req=$req"
curl -ksd "{$req}" ${MAIN_HTTP} curl -ksd "{$req}" "${http}"
exit 1 exit 1
fi fi
else else
...@@ -115,8 +115,9 @@ chain33_SendToAddress() { ...@@ -115,8 +115,9 @@ chain33_SendToAddress() {
[ "$ok" == true ] [ "$ok" == true ]
rst=$? rst=$?
echo_rst "$FUNCNAME" "$rst" echo_rst "$FUNCNAME" "$rst"
txhash=$(jq -r ".result" <<<"$resp") txhash=$(jq -r ".result.hash" <<<"$resp")
query_tx "$txhash" echo "tx hash: $txhash"
query_tx "$txhash" "${http}"
} }
chain33_SendTransaction() { chain33_SendTransaction() {
...@@ -136,9 +137,9 @@ chain33_SendTransaction() { ...@@ -136,9 +137,9 @@ chain33_SendTransaction() {
rst=$? rst=$?
echo_rst "$FUNCNAME" "$rst" echo_rst "$FUNCNAME" "$rst"
#返回交易 #返回交易
gResp=$(echo "${resp}" | jq -r ".result") gResp=$(jq -r ".result" <<<"$resp")
echo "tx hash is $gResp" echo "tx hash is $gResp"
query_tx "$gResp" query_tx "$gResp" "${MAIN_HTTP}"
} }
blackwhite_BlackwhiteCreateTx() { blackwhite_BlackwhiteCreateTx() {
...@@ -299,4 +300,10 @@ function main() { ...@@ -299,4 +300,10 @@ function main() {
fi fi
} }
main "$1" function debug_function() {
set -x
eval "$@"
set +x
}
debug_function main "$1"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment