mempool-startos/assets/utils/check-synced.sh
Lucy fd36160218
remove proxy as a dependency option and require bitcoin core (#23)
* remove proxy as a dependency option and require bitcoin core

* update release notes

* remove deprecated config key
2023-07-10 12:20:34 -04:00

40 lines
1.6 KiB
Bash

#!/bin/bash
set -e
sleep 15
b_host="bitcoind.embassy"
b_username=$(yq e '.bitcoin-user' /root/start9/config.yaml)
b_password=$(yq e '.bitcoin-password' /root/start9/config.yaml)
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":\).*/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":true\).*/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')
check_sync(){
DURATION=$(</dev/stdin)
if (($DURATION <= 5000 )); then
exit 60
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
elif test "$TXINDEX_CHECK" != 1; then
echo "Transaction Indexer is not enabled. Mempool will not display properly." >&2
exit 1
elif test "$TXINDEX_SYNC" != 1; then
echo "Transaction Indexer is still syncing. Mempool will not display correctly until sync is complete." >&2
exit 61
fi
}
case "$1" in
sync)
check_sync
;;
*)
echo "Usage: $0 [command]"
echo
echo "Commands:"
echo " sync"
esac