Browse Source

scan percent 2 blockheight

#146
rootzoll 6 years ago
parent
commit
e246eb4d3a
  1. 23
      home.admin/80scanLND.sh

23
home.admin/80scanLND.sh

@ -11,21 +11,18 @@ localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1
item=0 item=0
blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo) blockchaininfo=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo)
chain="$(echo "${blockchaininfo}" | jq -r '.chain')" chain="$(echo "${blockchaininfo}" | jq -r '.chain')"
gotData=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c "(height") item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "Caught up to height" | tail -ut -d ']' -f2 | tr -dc '0-9')
if [ ${gotData} -gt 0 ]; then if [ ${#item} -eq 0 ]; then
item=$(sudo -u bitcoin tail -n 100 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep "(height" | tail -n1 | awk '{print $10} {print $11} {print $12}' | tr -dc '0-9') # TODO add fallback later here if necessary
item="?"
fi fi
# get total number of blocks # get total number of blocks
total=$(echo "${blockchaininfo}" | jq -r '.blocks') total=$(echo "${blockchaininfo}" | jq -r '.blocks')
progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')" # put scanstate
scanstate="${item}/${total}"
# calculate progress in percent # get blockchain sync progress
percent=$(awk "BEGIN { pc=100*${item}/${total}; i=int(pc); print (pc-i<0.5)?i:i+1 }") progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
if [ ${percent} -eq 100 ]; then
# normally if 100% gets calculated, item parsed the wrong height
percent=0
fi
# check if blockchain is still syncing # check if blockchain is still syncing
heigh=6 heigh=6
@ -44,11 +41,11 @@ if [ ${isInitialChainSync} -gt 0 ]; then
infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") infoStr=$(echo " Waiting for final Blockchain Sync\n Progress: ${progress}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.")
fi fi
else else
infoStr=$(echo " Lightning Rescanning Blockchain ${percent}%\n Please wait - this can take some time\n ssh admin@${localip}\n Password A") infoStr=$(echo " Lightning Rescanning Blockchain ${scanstate}\n Please wait - this can take some time\n ssh admin@${localip}\n Password A")
if [ "$USER" = "admin" ]; then if [ "$USER" = "admin" ]; then
heigh=5 heigh=5
width=53 width=53
infoStr=$(echo " Lightning Rescanning Blockchain ${percent}%\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.") infoStr=$(echo " Lightning Rescanning Blockchain ${scanstate}\n Please wait - this can take some long time.\n Its OK to close terminal and ssh back in later.")
fi fi
fi fi

Loading…
Cancel
Save