This commit is contained in:
Dread 2022-04-14 19:12:32 -04:00
parent dc52c10d2d
commit 1a05296491
2 changed files with 4 additions and 35 deletions

View File

@ -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=$(</dev/stdin)
if (($DURATION <= 5000 )); then
@ -26,6 +26,9 @@ check_sync(){
elif test "$TXINDEX_CHECK" != 1; then
echo "Transaction Indexer is either not enabled. Mempool will not display completely." >&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
}

View File

@ -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/stdin)
if (($DURATION <= 5000 )); then
@ -42,27 +28,8 @@ check_web(){
fi
}
check_sync(){
DURATION=$(</dev/stdin)
if (($DURATION <= 5000 )); then
exit 60
else
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' &>/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