Skip to content

Instantly share code, notes, and snippets.

@rafaribe
Last active December 11, 2021 16:21
Show Gist options
  • Save rafaribe/de6352c9d36af23c72d5fc7b53379084 to your computer and use it in GitHub Desktop.
Save rafaribe/de6352c9d36af23c72d5fc7b53379084 to your computer and use it in GitHub Desktop.
Helium Blockchain Miner Height Helper
#!/usr/bin/env bash
MINER_HEIGHT=$(curl -d '{"jsonrpc":"2.0","id":"id","method":"block_height","params":[]}' -s -o - http://localhost:4467/|jq .result.height)
STAKEJOY_API_URL="https://helium-api.stakejoy.com"
HELIUM_API_URL="https://api.helium.io"
BLOCKCHAIN_HEIGHT=`curl -s -A "Wget/1.12 (linux-gnu)" $STAKEJOY_API_URL/v1/blocks/height | jq '.data.height'`
NEBRA_SNAPSHOT=$(wget -q https://helium-snapshots.nebra.com/latest.json -O - | grep -Po '\"height\": [0-9]*' | sed 's/\"height\": //')
SYNC_PERCENTAGE=$(echo "scale=2; ($MINER_HEIGHT / $BLOCKCHAIN_HEIGHT)*100" | bc)
echo "Latest Snapshot: $NEBRA_SNAPSHOT"
echo "Blockchain Height: $MINER_HEIGHT/$BLOCKCHAIN_HEIGHT - $SYNC_PERCENTAGE%"
@rafaribe
Copy link
Author

Shows this output.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment