From d7b36215770023fc0f5b625000b6f2cc34aa9f88 Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 25 Jun 2020 00:56:12 +0200 Subject: [PATCH 1/8] Fix logo for history --- g1-stats.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g1-stats.sh b/g1-stats.sh index bfb6518..5627e1c 100755 --- a/g1-stats.sh +++ b/g1-stats.sh @@ -141,7 +141,7 @@ web() { if [[ "$startTime" == "00:00" ]]; then cp $indexhtml $WEBPATH/history/index_$day.html sed -i "s/css\/style.css/..\/css\/style.css/g" $WEBPATH/history/index_$day.html - sed -i "s/logo-axiom-team2.svg/..\/logo-axiom-team2.svg/g" $WEBPATH/history/index_$day.html + sed -i "s/logo-axiom-team.svg/..\/logo-axiom-team.svg/g" $WEBPATH/history/index_$day.html sed -i "s/_dateNext/$day/g" $WEBPATH/history/index_$datePrevious.html sed -i "s/style=\"display:none;\" class=\"next\"/class=\"next\"/g" $WEBPATH/history/index_$datePrevious.html fi From a566b515b3997ca593f4d5e7b09ab8d91e37d09b Mon Sep 17 00:00:00 2001 From: poka Date: Thu, 25 Jun 2020 21:49:54 +0200 Subject: [PATCH 2/8] Check just one node --- g1-stats.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/g1-stats.sh b/g1-stats.sh index bfb6518..eb3af07 100755 --- a/g1-stats.sh +++ b/g1-stats.sh @@ -21,8 +21,8 @@ echo -e "\n############# $day à $startTime #############\n" echo "Initialisation ..." outFile="/tmp/g1-stats-$day-$startTime_$id" TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]') -TXBLOCKS+=$(curl -s ${DUNITER2}/blockchain/with/tx | jq '.result.blocks[]') -TXBLOCKS+=$(curl -s ${DUNITER3}/blockchain/with/tx | jq '.result.blocks[]') +#TXBLOCKS+=$(curl -s ${DUNITER2}/blockchain/with/tx | jq '.result.blocks[]') +#TXBLOCKS+=$(curl -s ${DUNITER3}/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 '.results[].pubkey' | tr -d '"')) From 47fd650d80e32129ee668614ebe770c14a197170 Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 11 Sep 2020 23:45:01 +0200 Subject: [PATCH 3/8] Fix loopWalletUp By Matograine; Add cache for loopWalletUp --- .gitignore | 1 + g1-stats.sh | 147 ++++++++++++++++++++++++++++------------------------ 2 files changed, 79 insertions(+), 69 deletions(-) diff --git a/.gitignore b/.gitignore index fa438ce..47faf29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env renameHistory.sh +cache diff --git a/g1-stats.sh b/g1-stats.sh index 7a549af..5663474 100755 --- a/g1-stats.sh +++ b/g1-stats.sh @@ -14,18 +14,14 @@ if [[ -e $SCRIPTPATH/.env ]]; then source $SCRIPTPATH/.env; else echo "Veuillez startTime=$(date +'%H:%M') day=$(date +'%y-%m-%d') dayP=$(date +'%d-%m-%y') -id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) indexhtml="$WEBPATH/index.html" echo -e "\n############# $day à $startTime #############\n" [[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc echo "Initialisation ..." -outFile="/tmp/g1-stats-$day-$startTime_$id" TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]') -#TXBLOCKS+=$(curl -s ${DUNITER2}/blockchain/with/tx | jq '.result.blocks[]') -#TXBLOCKS+=$(curl -s ${DUNITER3}/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 '.results[].pubkey' | tr -d '"')) +MEMBERS=($(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')) nbrMembers=${#MEMBERS[@]} lastBloc=${TXBLOCKS[-1]} isWeb=$1 @@ -33,59 +29,73 @@ isWeb=$1 ### Extraction des adresses Ḡ1 actives ### loopWalletUp() { - for i in ${TXBLOCKS[*]}; do - [[ -z ${TXBLOCKS[$i]} ]] && break - sleep 0.1 - WALLETS0=$(curl -s ${DUNITER}/blockchain/block/${TXBLOCKS[$i]}) - until WALLETS=$(echo $WALLETS0 | jq '.transactions[].outputs[]' 2>/dev/null); do + local iter=0 + local REGEX_PUBKEYS="[a-zA-Z0-9]{42,44}" + + if ls $SCRIPTPATH/cache/walletsUp-* > /dev/null 2>&1; then + local startFile=$(ls $SCRIPTPATH/cache/walletsUp-* | tail -n1) + local startBloc=$(echo "$startFile" | awk -F '-' '{ print $NF }') + wallets=$(cat "$startFile")$'\n' + local iter=$startBloc + rm $startFile + else + local startBloc=0 + local iter=0 + fi + + for i in ${TXBLOCKS[*]:$startBloc}; do # pour tout n° de bloc listé dans TXBLOCKS + sleep 0.02 + local WALLETS0=$(curl -s ${DUNITER}/blockchain/block/$i) + until local 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/${TXBLOCKS[$i]}) + WALLETS0=$(curl -s ${DUNITER}/blockchain/block/$i) done - [[ -z "$WALLETS" ]] && echo "Erreur: $RET" && exit 1 - WALLETS=$(echo "$WALLETS" | tr -d '"' | awk -F '(' '{ print $2 }' | tr -d ')') - bloc=${TXBLOCKS[$i]} + [[ -z "$WALLETS" ]] && continue wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g') - progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc) - - + local progress=$(echo "scale=1; $i*100/$lastBloc/1" | bc) if [[ $isWeb != "web" ]]; then clear echo "Heure de début: $startTime" echo - echo "Scan en cours: $progress% - $bloc/$lastBloc" + echo "Scan en cours: $progress% - $i/$lastBloc" fi ((iter++)) - + echo $iter; [[ $iter -ge 25 ]] && break #kopa done + + # On supprime les doublons et les lignes vides + wallets=$(echo -e "$wallets" | sort -u | awk 'NF') + # On écrit les pubkeys avec transaction dans un fichier de cache pour la prochaine itération + ((iter--)) + [[ ! -d $SCRIPTPATH/cache ]] && mkdir $SCRIPTPATH/cache + echo "$wallets" > $SCRIPTPATH/cache/walletsUp-$iter } loopWalletUp -### Ecriture des adresses actives dans un fichier tampon ### -echo -e "$(echo -e "$wallets" | sort -u)" > $outFile +exit #kopa ### Ajout des membres sans transaction au fichier tampon ### loopMembers() { -iter=0 +local iter=0 for i in ${MEMBERS[*]}; do - - progress=$(echo "scale=0; $iter*100/$nbrMembers/1" | bc) + local progress=$(echo "scale=0; $iter*100/$nbrMembers/1" | bc) if [[ $progress =~ ^(0|10|20|30|40|50|60|70|80|90|99)$ ]]; then [[ $progress == 99 ]] && progress=100 if [[ $isWeb != "web" ]]; then clear echo "Heure de début: $startTime" echo - echo "Scan en cours: 100% - $bloc/$lastBloc" + echo "Scan en cours: 100% - $lastBloc/$lastBloc" echo "Ajouts des comptes membres ... $progress%" fi fi - if [[ -z $(grep "$i" $outFile) ]]; then - echo -e "$i" >> $outFile + if [[ -z $(echo "$wallets" | grep "$i") ]]; then + wallets+=$'\n'"$i" fi ((iter++)) @@ -94,7 +104,7 @@ done loopMembers ### Calcul du nombre de wallets ### -nbrTotalWallets=$(cat $outFile | wc -l) +nbrTotalWallets=$(echo "$wallets" | wc -l) nbrSimpleWallets=$(echo "$nbrTotalWallets-$nbrMembers" | bc) pourcentMbrs=$(echo "scale=1; $nbrMembers*100/$nbrTotalWallets/1" | bc) pourcentWallets=$(echo "scale=1; $nbrSimpleWallets*100/$nbrTotalWallets/1" | bc) @@ -108,9 +118,9 @@ web() { [ ! -d $WEBPATH/js ] && cp -r $SCRIPTPATH/tpl/js $WEBPATH/ cp $SCRIPTPATH/tpl/index.html $indexhtml - datePrevious=$(date +'%y-%m-%d' -d "$day -1 day") + local datePrevious=$(date +'%y-%m-%d' -d "$day -1 day") [[ -z $(ls -l $WEBPATH/history/ | grep $datePrevious) && -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/class=\"previous\"/style=\"display:none;\" class=\"previous\"/g" $indexhtml - dateNext=$(date +'%y-%m-%d' -d "$day +1 day") + local dateNext=$(date +'%y-%m-%d' -d "$day +1 day") [[ -z $(ls -l $WEBPATH/history/ | grep $dateNext) && -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/class=\"next\"/style=\"display:none;\" class=\"next\"/g" $indexhtml sed -i "s/_nbrTotalWallets/$nbrTotalWallets/g" $indexhtml @@ -120,21 +130,21 @@ web() { sed -i "s/_pourcentWallets/$pourcentWallets/g" $indexhtml # sed -i "s/_node/$DUNITER/g" $indexhtml sed -i "s/_heure/$startTime/g" $indexhtml - sed -i "s/_day/$dayP/g" $indexhtml + sed -i "s/_day/$dayP/g" $indexhtml sed -i "s/_txInSimple/$txInSimple/g" $indexhtml sed -i "s/_txOutSimple/$txOutSimple/g" $indexhtml sed -i "s/_soldeSimple/$soldeSimple/g" $indexhtml - sed -i "s/_txInMembers/$txInMembers/g" $indexhtml - sed -i "s/_txOutMembers/$txOutMembers/g" $indexhtml - sed -i "s/_soldeMembers/$soldeMembers/g" $indexhtml + sed -i "s/_txInMembers/$txInMembers/g" $indexhtml + sed -i "s/_txOutMembers/$txOutMembers/g" $indexhtml + sed -i "s/_soldeMembers/$soldeMembers/g" $indexhtml sed -i "s/_pourcentSimpleWallet/$pourcentSimpleWallet/g" $indexhtml sed -i "s/_nonConsumedUDT/$nonConsumedUDT/g" $indexhtml - sed -i "s/_monetaryMass/$monetaryMass/g" $indexhtml + sed -i "s/_monetaryMass/$monetaryMass/g" $indexhtml sed -i "s/_sleepyG1/$sleepyG1/g" $indexhtml - [[ -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/_datePrevious/$datePrevious/g" $indexhtml && setPrevious="Oui" - [[ -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/_dateNext/$dateNext/g" $indexhtml && setNext="Oui" + [[ -z $(grep '"display:none;" class="previous"' $indexhtml) ]] && sed -i "s/_datePrevious/$datePrevious/g" $indexhtml && setPrevious="Oui" + [[ -z $(grep '"display:none;" class="next"' $indexhtml) ]] && sed -i "s/_dateNext/$dateNext/g" $indexhtml && setNext="Oui" - cat "$outFile" | grep . > $WEBPATH/wallets-g1.txt + echo "$wallets" | grep . > $WEBPATH/wallets-g1.txt echo -e "${MEMBERS[@]}" | sed 's/ /\n/g' > $WEBPATH/wallets-g1-membres.txt echo -e "$simpleWallets" > $WEBPATH/wallets-g1-simple.txt @@ -164,7 +174,7 @@ echo "Extraction wallets membres / Simples portefeuille" echo -e "\n ---\n" ### Isolation des simples portefeuilles ### -simpleWallets=$(cat $outFile) +simpleWallets="$wallets" echo "Isolation des simples portefeuilles..." for i in ${MEMBERS[@]}; do simpleWallets=$(echo "$simpleWallets" | grep -v "$i") @@ -172,36 +182,36 @@ done ### Boucle d'obtention des soldes ### getSolde(){ -solde=0 -txInT=0 -txOutT=0 -nonConsumedUDT=0 -nonConsumedUD=0 -for i in $pubkeys; do - until txInL=$(curl -s "$ESNODE/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=recipient:$i&pretty"); do - echo "Erreur: $i" - sleep 2 + solde=0 + txInT=0 + txOutT=0 + nonConsumedUDT=0 + nonConsumedUD=0 + for i in $pubkeys; do + until txInL=$(curl -s "$ESNODE/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=recipient:$i&pretty"); do + echo "Erreur: $i" + sleep 1 + done + until txOutL=$(curl -s "$ESNODE/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty"); do + echo "Erreur: $i" + sleep 1 + done + + if [[ $1 == "mbr" ]]; then + nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0 + [[ -z $nonConsumedUD ]] && nonConsumedUD=0 + nonConsumedUDT=$(echo -e "scale=2; ($nonConsumedUD/100)+$nonConsumedUDT" | bc) + fi + + [[ $txInL != "{ }" ]] && txIn=$(echo "$txInL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txIn=0 + [[ $txOutL != "{ }" ]] && txOut=$(echo "$txOutL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txOut=0 + + solde=$(echo -e "scale=2; (($txIn-$txOut+$nonConsumedUD)/100)+$solde" | bc) + + txInT=$(echo -e "scale=2; (($txIn+$nonConsumedUD)/100)+$txInT" | bc) + txOutT=$(echo -e "scale=2; ($txOut/100)+$txOutT" | bc) + done - until txOutL=$(curl -s "$ESNODE/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty"); do - echo "Erreur: $i" - sleep 2 - done - - if [[ $1 == "mbr" ]]; then - nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0 - [[ -z $nonConsumedUD ]] && nonConsumedUD=0 - nonConsumedUDT=$(echo -e "scale=2; ($nonConsumedUD/100)+$nonConsumedUDT" | bc) - fi - - [[ $txInL != "{ }" ]] && txIn=$(echo "$txInL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txIn=0 - [[ $txOutL != "{ }" ]] && txOut=$(echo "$txOutL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txOut=0 - - solde=$(echo -e "scale=2; (($txIn-$txOut+$nonConsumedUD)/100)+$solde" | bc) - - txInT=$(echo -e "scale=2; (($txIn+$nonConsumedUD)/100)+$txInT" | bc) - txOutT=$(echo -e "scale=2; ($txOut/100)+$txOutT" | bc) - -done } echo "Récupération du solde des simples wallets..." @@ -249,6 +259,5 @@ echo -e "$sleepyG1% des Ḡ1 n'ont jamais été utilisés." [[ $isWeb == "web" ]] && web ### Fin de programme ### -rm $outFile day=$(date +'%d-%m-%y') echo "$day - Heure de fin: $(date +'%H:%M')" From 23cc65609b15bdbd7a07a45f6ef5e1e2be53e9c2 Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 11 Sep 2020 23:45:32 +0200 Subject: [PATCH 4/8] Fix loopWalletUp By Matograine; Add cache for loopWalletUp --- g1-stats.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g1-stats.sh b/g1-stats.sh index 5663474..6806669 100755 --- a/g1-stats.sh +++ b/g1-stats.sh @@ -64,7 +64,7 @@ loopWalletUp() { fi ((iter++)) - echo $iter; [[ $iter -ge 25 ]] && break #kopa + ## echo $iter; [[ $iter -ge 25 ]] && break #kopa done # On supprime les doublons et les lignes vides From 424b99c6f1e686f5af9c434dc4b7323af18d180e Mon Sep 17 00:00:00 2001 From: poka Date: Sat, 12 Sep 2020 02:57:07 +0200 Subject: [PATCH 5/8] Fix loopWalletUp By Matograine; Add cache for loopWalletUp #3 --- g1-stats.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/g1-stats.sh b/g1-stats.sh index 6806669..4cb47ab 100755 --- a/g1-stats.sh +++ b/g1-stats.sh @@ -76,8 +76,6 @@ loopWalletUp() { } loopWalletUp -exit #kopa - ### Ajout des membres sans transaction au fichier tampon ### loopMembers() { local iter=0 From 3e0b1b18812b8ce5cdb162d7535a70c4ab93154d Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 13 Sep 2020 01:01:22 +0200 Subject: [PATCH 6/8] Debug mode --- g1-stats.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/g1-stats.sh b/g1-stats.sh index 4cb47ab..309e631 100755 --- a/g1-stats.sh +++ b/g1-stats.sh @@ -18,7 +18,8 @@ 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=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]') +TXBLOCKS=$(cat blocsUp.txt) TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}')) unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]' MEMBERS=($(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')) @@ -43,16 +44,21 @@ loopWalletUp() { local iter=0 fi + rm -f $SCRIPTPATH/debug.log for i in ${TXBLOCKS[*]:$startBloc}; do # pour tout n° de bloc listé dans TXBLOCKS - sleep 0.02 + echo "Boucle: $iter +BLoc: $i" >> $SCRIPTPATH/debug.log + + sleep 0.1 local WALLETS0=$(curl -s ${DUNITER}/blockchain/block/$i) - until local 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" + 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 sleep 2 WALLETS0=$(curl -s ${DUNITER}/blockchain/block/$i) done - [[ -z "$WALLETS" ]] && continue + [[ -z "$WALLETS" ]] && echo "$WALLETS est vide, on zap..." >> $SCRIPTPATH/debug.log && continue wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g') local progress=$(echo "scale=1; $i*100/$lastBloc/1" | bc) @@ -64,7 +70,9 @@ loopWalletUp() { fi ((iter++)) - ## echo $iter; [[ $iter -ge 25 ]] && break #kopa + + ## [[ $iter -ge 25 ]] && break #kopa + echo "---" >> $SCRIPTPATH/debug.log done # On supprime les doublons et les lignes vides @@ -164,9 +172,9 @@ web() { ### Affichage du nombre de wallets ### echo -e "\n ---\n" echo "Noeud: $DUNITER" -echo "Nombre total de wallet: $nbrTotalWallets" -echo "Nombre de membres: $nbrMembers (${pourcentMbrs}%)" -echo "Nombre de simple portefeuille: $nbrSimpleWallets (${pourcentWallets}%)" +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 -e "\n ---\n" echo "Extraction wallets membres / Simples portefeuille" echo -e "\n ---\n" From c7a864a18f9c13e93d44b91458e641620a2cafba Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 13 Sep 2020 01:02:56 +0200 Subject: [PATCH 7/8] Add disclaimer --- tpl/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tpl/index.html b/tpl/index.html index 48a53bf..78c9392 100644 --- a/tpl/index.html +++ b/tpl/index.html @@ -9,6 +9,8 @@

La Ḡ1 en quelques chiffres

+

Attention: ces données sont encore expérimentales, considérez les avec précaution.

+

Vous trouverez des statistiques plus détaillées via l'explorateur Cesium

Voir les graphiques
From d70bde55573ada8bae6992bab29e7fe6f46a3741 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 13 Sep 2020 04:03:10 +0200 Subject: [PATCH 8/8] 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"