Created
May 2, 2018 09:01
-
-
Save nicovs/4f5db76f43cc7e250fdc80600e98637f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
EXPLORERAPI=https://explorer.nycoin.community/api | |
BLOCKHIGHT=$(curl -s "$EXPLORERAPI/getblockcount") | |
calc(){ awk "BEGIN{ print $* }" ;} | |
echo "[" | |
for i in {16376..$BLOCKHIGHT..16376} | |
do | |
HASH=$(curl -s "$EXPLORERAPI/getblockhash?index=$i") | |
sleep 1 | |
DATA=$(curl -s "$EXPLORERAPI/getblock?hash=$HASH") | |
BITS=$(echo $DATA | jq -r ' .bits') | |
TIME=$(echo $DATA | jq -r ' .time') | |
EXP="$((16#${BITS:0:2}))" | |
C=$(echo $BITS | sed 's/^..//') | |
COEF=$((16#${C})) | |
echo " [" | |
echo " \"$HASH\"," | |
echo " $(calc "($COEF*(2^(8*($EXP-3))))")," | |
echo " $TIME" | |
echo " ]," | |
sleep 1 | |
done | |
echo "]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment