From 62b748bb8f2f9d9bbd7f74e9fc403934a2209ca5 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Tue, 25 May 2021 20:19:22 -0500 Subject: [PATCH] blockchain screen --- home.admin/00raspiblitz.sh | 17 +++- .../setup.scripts/eventBlockchainSync.sh | 83 +++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 home.admin/setup.scripts/eventBlockchainSync.sh diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 33f893c44..4c854e071 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -5,7 +5,7 @@ # gets called when user logins per SSH # or calls 'raspiblitz' on the terminal ####################################### -echo "Starting SSH user interface ..." +echo "Starting SSH user interface ... (please wait)" # CONFIGFILE - configuration of RaspiBlitz configFile="/mnt/hdd/raspiblitz.conf" @@ -47,6 +47,7 @@ sudo chmod 740 /var/cache/raspiblitz/raspiblitz.status ##################################### exitMenuLoop=0 +doneIBD=0 while [ ${exitMenuLoop} -eq 0 ] do @@ -97,6 +98,20 @@ do state="starting" fi + ##################################### + # INITIAL BLOCKCHAIN SYNC + ##################################### + if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ] && [ ${doneIBD} -eq 0 ]; then + # check if initial Blockchain sync is in progress + echo "Gathering Info ... (please wait)" + source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) + if [ "${syncedToChain}" == "0" ]; then + + fi + doneIBD=1 + fi + + ##################################### # MAIN MENU or BLOCKCHAIN SYNC ##################################### diff --git a/home.admin/setup.scripts/eventBlockchainSync.sh b/home.admin/setup.scripts/eventBlockchainSync.sh new file mode 100644 index 000000000..222028dee --- /dev/null +++ b/home.admin/setup.scripts/eventBlockchainSync.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# this is an dialog that handles all UI events during setup that require a "info & wait" with no interaction + +# get basic system information +# these are the same set of infos the WebGUI dialog/controler has +source /home/admin/_version.info +source /home/admin/raspiblitz.info + +# 1st PARAMETER: ssh|lcd +lcd=0 +if [ "$1" == "lcd" ]; then + lcd=1 +fi + +# 2nd PARAMETER (optional): -loop-until-synced +loopUntilSynced=0 +if [ "$2" == "-loop-until-synced" ]; then + loopUntilSynced=1 +fi + +loop=1 +while [ ${loop} -eq 1 ] +do + + # get fresh data + source <(sudo /home/admin/config.scripts/blitz.statusscan.sh) + + # display blockchain sync + height=6 + width=45 + actionString="Please wait - this can take some time" + + # formatting BLOCKCHAIN SYNC PROGRESS + if [ "${syncProgress}" == "" ]; then + if [ ${startcountBlockchain} -lt 2 ]; then + syncProgress="waiting" + else + syncProgress="${startcountBlockchain} restarts" + fi + elif [ ${#syncProgress} -lt 6 ]; then + syncProgress=" ${syncProgress} % ${peers} peers" + else + syncProgress="${syncProgress} % ${peers} peers" + fi + + # formatting LIGHTNING SCAN PROGRESS + if [ "${scanProgress}" == "" ]; then + # in case of LND RPC is not ready yet + if [ ${scanTimestamp} -eq -2 ]; then + scanProgress="prepare sync" + # in case LND restarting >2 + elif [ ${startcountLightning} -gt 2 ]; then + scanProgress="${startcountLightning} restarts" + # unkown cases + else + scanProgress="waiting" + fi + elif [ ${#scanProgress} -lt 6 ]; then + scanProgress=" ${scanProgress} %" + else + scanProgress="${scanProgress} %" + fi + + # setting info string + infoStr=" Blockchain Progress : ${syncProgress}\n Lightning Progress : ${scanProgress}\n ${actionString}" + + # set admin string + if [ ${lcd} -eq 1 ]; then + adminStr="ssh admin@${localip} ->Password A" + else + adminStr="Use CTRL+c to EXIT to Terminal" + fi + + # display info to user + dialog --title " Node is Syncing " --backtitle "RaspiBlitz ${codeVersion} ${hostname} / ${network} / ${chain} / ${tempCelsius}°C" --infobox "${infoStr}\n ${adminStr}" ${height} ${width} + + # determine to loop or not + loop=0 + if [ ${loopUntilSynced} -eq 1 ] && [ "${syncedToChain}" == "0" ]; then + # loop until synced to chain + loop=1 + fi +done \ No newline at end of file