From d70bde55573ada8bae6992bab29e7fe6f46a3741 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 13 Sep 2020 04:03:10 +0200 Subject: [PATCH] Fix until local loop, didn't match errors --- g1-stats.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/g1-stats.sh b/g1-stats.sh index 309e631..60f3d52 100755 --- a/g1-stats.sh +++ b/g1-stats.sh @@ -18,8 +18,7 @@ indexhtml="$WEBPATH/index.html" echo -e "\n############# $day à $startTime #############\n" [[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc echo "Initialisation ..." -#TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]') -TXBLOCKS=$(cat blocsUp.txt) +TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]') TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}')) unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]' MEMBERS=($(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')) @@ -44,21 +43,16 @@ loopWalletUp() { local iter=0 fi - rm -f $SCRIPTPATH/debug.log for i in ${TXBLOCKS[*]:$startBloc}; do # pour tout n° de bloc listé dans TXBLOCKS - echo "Boucle: $iter -BLoc: $i" >> $SCRIPTPATH/debug.log - - sleep 0.1 + sleep 0.05 local WALLETS0=$(curl -s ${DUNITER}/blockchain/block/$i) - until local WALLETS=$(echo $WALLETS0 | jq -r '.transactions[].outputs[]' 2>>$SCRIPTPATH/debug.log | grep "SIG" | grep -Eo $REGEX_PUBKEYS); do - #[[ $isWeb != "web" ]] && - echo -e "iter $iter \n$WALLETS0" >> $SCRIPTPATH/debug.log + until WALLETS=$(echo $WALLETS0 | jq -r '.transactions[].outputs[]' 2>/dev/null | grep "SIG" | grep -Eo $REGEX_PUBKEYS); do + [[ $isWeb != "web" ]] && echo -e "iter $iter \n$WALLETS0" sleep 2 WALLETS0=$(curl -s ${DUNITER}/blockchain/block/$i) done - [[ -z "$WALLETS" ]] && echo "$WALLETS est vide, on zap..." >> $SCRIPTPATH/debug.log && continue + [[ -z "$WALLETS" ]] && echo "$WALLETS est vide, on zap..." && continue wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g') local progress=$(echo "scale=1; $i*100/$lastBloc/1" | bc) @@ -72,7 +66,6 @@ BLoc: $i" >> $SCRIPTPATH/debug.log ((iter++)) ## [[ $iter -ge 25 ]] && break #kopa - echo "---" >> $SCRIPTPATH/debug.log done # On supprime les doublons et les lignes vides @@ -172,9 +165,9 @@ web() { ### Affichage du nombre de wallets ### echo -e "\n ---\n" echo "Noeud: $DUNITER" -echo "Nombre total de wallet: $nbrTotalWallets" >> $SCRIPTPATH/debug.log #kopa -echo "Nombre de membres: $nbrMembers (${pourcentMbrs}%)" >> $SCRIPTPATH/debug.log #kopa -echo "Nombre de simple portefeuille: $nbrSimpleWallets (${pourcentWallets}%)" >> $SCRIPTPATH/debug.log #kopa +echo "Nombre total de wallet: $nbrTotalWallets" +echo "Nombre de membres: $nbrMembers (${pourcentMbrs}%)" +echo "Nombre de simple portefeuille: $nbrSimpleWallets (${pourcentWallets}%)" echo -e "\n ---\n" echo "Extraction wallets membres / Simples portefeuille" echo -e "\n ---\n"