diff --git a/assets/utils/check-synced.sh b/assets/utils/check-synced.sh index a527c7f..a7f4ff0 100644 --- a/assets/utils/check-synced.sh +++ b/assets/utils/check-synced.sh @@ -15,7 +15,7 @@ fi TXINDEX_CHECK=$(curl -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getindexinfo", "params": ["txindex"]}' -H 'content-type: text/plain;' $b_host:8332 | sed -n 's/.*\("synced":true\).*/1/p') TXINDEX_SYNC=$(curl -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getindexinfo", "params": ["txindex"]}' -H 'content-type: text/plain;' $b_host:8332 | sed -n 's/.*\("synced":false\).*/1/p') IBD_STATE=$(curl -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getblockchaininfo", "params": []}' -H 'content-type: text/plain;' $b_host:8332 | sed -n 's/.*\("initialblockdownload":false\).*/1/p') -TXINDEX_SYNC=$TXINDEX_SYNC+$IBD_STATE + check_sync(){ DURATION=$(&2 exit 1 + elif test "$IBD_STATE" != 1; then + echo "Initial blockchain download still in progress. Mempool will not display correctly until this is complete." >&2 + exit 61 fi } diff --git a/assets/utils/health-check.sh b/assets/utils/health-check.sh index ab1c7b3..d77d251 100644 --- a/assets/utils/health-check.sh +++ b/assets/utils/health-check.sh @@ -1,19 +1,5 @@ #!/bin/sh -CURRENT_HEIGHT=$(wget -q -O- https://blockchain.info/q/getblockcount; echo) -b_type=$(yq e '.bitcoind.type' /root/start9/config.yaml) -if [ "$b_type" = "internal" ]; then - b_host="bitcoind.embassy" - b_username=$(yq e '.bitcoind.user' /root/start9/config.yaml) - b_password=$(yq e '.bitcoind.password' /root/start9/config.yaml) -else - b_host="btc-rpc-proxy.embassy" - b_username=$(yq e '.bitcoind.user' /root/start9/config.yaml) - b_password=$(yq e '.bitcoind.password' /root/start9/config.yaml) -fi -TXINDEX_CHECK=$(curl --silent --fail -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getrawtransaction", "params": [00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048]}' -H 'content-type: text/plain;' $b_host:8332/ | sed 's/[^0-9]*//g') -SYNC_HEIGHT=$(curl --silent --fail -sS --user $b_username:$b_password --data-binary '{"jsonrpc": "1.0", "id": "sync-hck", "method": "getblockcount", "params": []}' -H 'content-type: text/plain;' $b_host:8332/ | sed 's/[^0-9]*//g') - check_api(){ DURATION=$(/dev/null - RES=$? - if test "$RES" != 0; then - echo "The Bitcoin Core is unreachable" >&2 - exit 1 - elif test "$SYNC_HEIGHT" -lt "$CURRENT_HEIGHT"; then - echo "Bitcoin Core is still syncing, Mempool will not display completely until syncing is complete. Current block height: $SYNC_HEIGHT of $CURRENT_HEIGHT" >&2 - exit 61 - fi - fi -} case "$1" in - sync) - check_sync - ;; api) check_api ;; @@ -75,5 +42,4 @@ case "$1" in echo "Commands:" echo " api" echo " web" - echo " sync" esac \ No newline at end of file