We can now use notify_web response, sync block for newblock

This commit is contained in:
kexkey
2020-12-09 16:02:45 -05:00
parent fe3471b3c6
commit d03e802131
6 changed files with 15 additions and 4 deletions

View File

@@ -601,6 +601,7 @@ batch_webhooks() {
local body
local successful_recipient_ids
local returncode
local response
outputs=$(echo "${webhooks_data}" | jq -Mc ".[]")
@@ -626,7 +627,7 @@ batch_webhooks() {
body='{"outputId":'${output_id}',"address":'${address}',"amount":'${amount}','${tx}'}'
trace "[batch_webhooks] body=${body}"
notify_web "${webhook_url}" "${body}" ${TOR_ADDR_WATCH_WEBHOOKS}
response=$(notify_web "${webhook_url}" "${body}" ${TOR_ADDR_WATCH_WEBHOOKS})
returncode=$?
trace_rc ${returncode}

View File

@@ -253,8 +253,9 @@ curl_callback() {
trace "Entering curl_callback()..."
local returncode
local response
notify_web "${1}" "${2}" ${TOR_ADDR_WATCH_WEBHOOKS}
response=$(notify_web "${1}" "${2}" ${TOR_ADDR_WATCH_WEBHOOKS})
returncode=$?
trace_rc ${returncode}

View File

@@ -147,8 +147,9 @@ curl_callback_txid() {
trace "Entering curl_callback_txid()..."
local returncode
local response
notify_web "${1}" "${2}" ${TOR_TXID_WATCH_WEBHOOKS}
response=$(notify_web "${1}" "${2}" ${TOR_TXID_WATCH_WEBHOOKS})
returncode=$?
trace_rc ${returncode}

View File

@@ -6,6 +6,9 @@
. ./batching.sh
newblock() {
(
flock -x 202
trace "Entering newblock()..."
local request=${1}
@@ -24,4 +27,6 @@ newblock() {
do_callbacks_txid
batch_check_webhooks
) 202>./.newblock.lock
}

View File

@@ -37,6 +37,8 @@ notify_web() {
http_code=$(echo "${response}" | jq -r ".http_code")
trace "[notify_web] http_code=${http_code}"
echo "${response}"
if [ "${curl_code}" -eq "0" ] && [ "${returncode}" -eq "0" ]; then
if [ "${http_code}" -lt "400" ]; then
return 0

View File

@@ -150,6 +150,7 @@ serve_ots_backoffice() {
local result
local returncode
local response
# Let's fetch all the incomplete stamping request
local callbacks=$(sql 'SELECT hash, callbackUrl, requested, upgraded, id FROM stamp WHERE NOT calledback')
@@ -213,7 +214,7 @@ serve_ots_backoffice() {
if [ -n ${url} ]; then
trace "[serve_ots_backoffice] url is not empty, now trying to call it!"
notify_web "${url}" ${TOR_OTS_WEBHOOKS}
response=$(notify_web "${url}" ${TOR_OTS_WEBHOOKS})
returncode=$?
trace_rc ${returncode}