Skip to content

Instantly share code, notes, and snippets.

@yebyen
Created September 22, 2013 03:42
Show Gist options
  • Save yebyen/6656475 to your computer and use it in GitHub Desktop.
Save yebyen/6656475 to your computer and use it in GitHub Desktop.
How many blocks til TerraCoin next difficulty rally, my ASIC bros? 1382. (could be off by one)
#!/usr/bin/env bash
dfc=$(terracoind getdifficulty)
firstheight=$(terracoind getblockcount)
height=$firstheight
hsh=$(terracoind getblockhash $height)
while [ -n "$dfc" ]; do
#echo $hsh
newdfc=$(terracoind getblock ${hsh}|grep "$dfc")
#echo $newdfc
if [ -z "$newdfc" ]; then break; fi
hsh=$(terracoind getblock ${hsh}|grep previousblockhash|awk '{print $3}'|sed -e 's/^"//' -e 's/",$//' -e 's/"$//')
dfc="$newdfc"
done
#echo $hsh
#echo $dfc
last_diff=$(terracoind getblock $hsh|grep height|sed -e 's/^ "height" : //' -e 's/,$//')
z=`expr $firstheight - $last_diff`
y=`expr 2160 - $z`
echo "Countdown: Num blocks til difficulty adjustment: $y blocks"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment