-
Notifications
You must be signed in to change notification settings - Fork 34
Description
prev_block=0; prev_time=$(date +%s); while true; do
resp=$(curl -s -X POST -H "Content-Type: application/json"
--data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'
http://localhost:8545)
current=$(echo "$resp" | jq -r '.result.currentBlock' | sed 's/^0x//')
highest=$(echo "$resp" | jq -r '.result.highestBlock' | sed 's/^0x//')
if [ "$current" = "false" ]; then
echo "[✓] Geth is fully synced!"
break
fi
current_dec=$((16#$current))
highest_dec=$((16#$highest))
percent=$((current_dec * 100 / highest_dec))
now=$(date +%s)
delta=$((now - prev_time))
blocks_done=$((current_dec - prev_block))
[
remaining=$((highest_dec - current_dec))
[
eta_h=$((eta_min / 60))
eta_m=$((eta_min % 60))
progress bar
bar_total=25
bar_fill=$((percent * bar_total / 100))
bar_empty=$((bar_total - bar_fill))
progress_bar=$(printf "%0.s█" $(seq 1
echo "📦 [$progress_bar]
prev_block=$current_dec
prev_time=$now
sleep 10
done