Refactor functions positions; replace membres ans simples wallets loops by grep -v
This commit is contained in:
parent
b9ff5a9e04
commit
1376e1621d
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cacheFile=$(ls cache/walletsUp-*)
|
|
||||||
cacheID=$(echo $cacheFile | awk -F '-' '{ print $NF }')
|
|
||||||
|
|
||||||
#rm -f cache/bk-walletsUp-*
|
|
||||||
cp $cacheFile cache/bk-walletsUp-$cacheID
|
|
||||||
cp db/recus.json db/bk-recus.json-$cacheID
|
|
||||||
|
|
87
g1-stats.sh
87
g1-stats.sh
|
@ -22,85 +22,36 @@ TXBLOCKS=$(cat $SCRIPTPATH/db/txblocs) #kopa
|
||||||
#TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
|
#TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
|
||||||
TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
|
TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
|
||||||
unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]'
|
unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]'
|
||||||
#MEMBERS=($(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey'))
|
#membresPubkeys=$(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')
|
||||||
MEMBERS=($(cat db/membresPubkeys)) #kopa
|
membresPubkeys=$(cat db/membresPubkeys) #kopa
|
||||||
nbrMembers=${#MEMBERS[@]}
|
nbrMembers=$(echo "$membresPubkeys" | wc -l)
|
||||||
lastBloc=${TXBLOCKS[-1]}
|
lastBloc=${TXBLOCKS[-1]}
|
||||||
isWeb=$1
|
isWeb=$1
|
||||||
|
|
||||||
### On source les fonctions ###
|
### On source les fonctions
|
||||||
source $SCRIPTPATH/functions.sh
|
source $SCRIPTPATH/lib/functions.sh
|
||||||
|
source $SCRIPTPATH/lib/scanTxWallets.sh
|
||||||
|
|
||||||
### Extraction des adresses Ḡ1 actives ###
|
### Extraction des adresses Ḡ1 actives
|
||||||
loopWalletUp
|
scanTxWallets
|
||||||
|
|
||||||
### Calcul la somme des soldes portefeuilles et membres ###
|
### Calcul la somme des soldes portefeuilles et membres
|
||||||
sumSoldes db/recus.json
|
sumSoldes
|
||||||
|
|
||||||
|
### Ajout des membres sans transaction
|
||||||
|
addMembers
|
||||||
|
|
||||||
#endDate=$(date +'%H:%M')
|
### Calcul du nombre de wallets
|
||||||
#echo "Heure de fin: $endDate"
|
nbrWallets
|
||||||
#exit
|
|
||||||
|
|
||||||
|
### Affichage des stats
|
||||||
|
displayStats
|
||||||
|
|
||||||
### Ajout des membres sans transaction au fichier tampon ###
|
### Renseignement de l'index web et indexation de l'historique
|
||||||
loopMembers
|
# source $SCRIPTPATH/lib/functions.sh # On source les fonctions de nouveau
|
||||||
|
|
||||||
### Calcul du nombre de wallets ###
|
|
||||||
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)
|
|
||||||
|
|
||||||
### Affichage des stats ###
|
|
||||||
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 -e "\n ---\n"
|
|
||||||
echo "Reçus Wallets: $sumRW"
|
|
||||||
echo "Reçus Membres: $sumRM"
|
|
||||||
echo "Reçus Total: $sumRT"
|
|
||||||
echo -e " ---"
|
|
||||||
echo "Envoyé Wallets: $sumSW"
|
|
||||||
echo "Envoyé Membres: $sumSM"
|
|
||||||
echo "Envoyé Total: $sumST"
|
|
||||||
echo -e " ---"
|
|
||||||
echo "Solde Wallets: $soldeW"
|
|
||||||
echo "Solde Membres: $soldeM"
|
|
||||||
echo -e " ---"
|
|
||||||
|
|
||||||
### Isolation des simples portefeuilles ###
|
|
||||||
simpleWallets="$wallets"
|
|
||||||
echo "Isolation des simples portefeuilles..."
|
|
||||||
for i in ${MEMBERS[@]}; do
|
|
||||||
simpleWallets=$(echo "$simpleWallets" | grep -v "$i")
|
|
||||||
done
|
|
||||||
|
|
||||||
##TODO: Get Solde from JSON Sum for next ... kopa
|
|
||||||
|
|
||||||
### Calcul de la masse monétaire et du pourcentage de Ḡ1 sur les simples portefeuilles ###
|
|
||||||
monetaryMass=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass)
|
|
||||||
monetaryMassBrut=$(echo -e "scale=2; ($monetaryMass/100)/1" | bc)
|
|
||||||
monetaryMass=$(echo "$monetaryMassBrut" | tr . , | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
|
|
||||||
soldeWalletMembers=$(echo "scale=2; $soldeMBrut+$soldeWBrut" | bc | tr . , | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
pourcentSimpleWallet=$(echo "scale=1; $soldeWBrut*100/$monetaryMassBrut/1" | bc)
|
|
||||||
|
|
||||||
echo -e " ---"
|
|
||||||
echo -e "Masse Monétaire:\t $monetaryMass Ḡ1"
|
|
||||||
|
|
||||||
# Analyse
|
|
||||||
echo -e "\n ---\n Analyse\n ---"
|
|
||||||
sleepyG1=$(echo -e "scale=1; 100-$sumSTBrut*100/$monetaryMassBrut" | bc | tr . ,)
|
|
||||||
echo -e "$sleepyG1% des Ḡ1 n'ont jamais été utilisés."
|
|
||||||
|
|
||||||
### Renseignement de l'index web et indexation de l'historique ###
|
|
||||||
source $SCRIPTPATH/functions.sh # On source les fonctions de nouveau
|
|
||||||
[[ $isWeb == "web" ]] && web
|
[[ $isWeb == "web" ]] && web
|
||||||
|
|
||||||
### Fin de programme ###
|
### Fin de programme
|
||||||
day=$(date +'%d-%m-%y')
|
day=$(date +'%d-%m-%y')
|
||||||
echo -e " ---"
|
echo -e " ---"
|
||||||
echo "$day - Heure de fin: $(date +'%H:%M')"
|
echo "$day - Heure de fin: $(date +'%H:%M')"
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
addMembers() {
|
||||||
|
echo -e "\nAjouts des comptes membres sans transaction reçus ..."
|
||||||
|
wallets="$wallets"'\n'"$membresPubkeys"
|
||||||
|
wallets=$(echo -e "$wallets" | sort -u)
|
||||||
|
|
||||||
|
echo "Isolation des simples portefeuilles..."
|
||||||
|
simpleWallets=$(echo "$wallets" | grep -v "$membresPubkeys")
|
||||||
|
}
|
||||||
|
|
||||||
|
web() {
|
||||||
|
|
||||||
|
[ ! -d $WEBPATH/history/ ] && mkdir -p $WEBPATH/history/
|
||||||
|
[ ! -d $WEBPATH/graph/ ] && mkdir -p $WEBPATH/graph/
|
||||||
|
[ ! -d $WEBPATH/css ] && cp -r $SCRIPTPATH/tpl/css $WEBPATH/
|
||||||
|
[ ! -d $WEBPATH/js ] && cp -r $SCRIPTPATH/tpl/js $WEBPATH/
|
||||||
|
cp $SCRIPTPATH/tpl/index.html $indexhtml
|
||||||
|
|
||||||
|
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")
|
||||||
|
[[ -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
|
||||||
|
sed -i "s/_nbrSimpleWallets/$nbrSimpleWallets/g" $indexhtml
|
||||||
|
sed -i "s/_nbrMembers/$nbrMembers/g" $indexhtml
|
||||||
|
sed -i "s/_pourcentMbrs/$pourcentMbrs/g" $indexhtml
|
||||||
|
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/_sumRW/$sumRW/g" $indexhtml
|
||||||
|
sed -i "s/_sumSW/$sumSW/g" $indexhtml
|
||||||
|
sed -i "s/_soldeW/$soldeW/g" $indexhtml
|
||||||
|
sed -i "s/_sumRM/$sumRM/g" $indexhtml
|
||||||
|
sed -i "s/_sumSM/$sumSM/g" $indexhtml
|
||||||
|
sed -i "s/_soldeM/$soldeM/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/_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"
|
||||||
|
|
||||||
|
echo "$wallets" | grep . > $WEBPATH/wallets-g1.txt
|
||||||
|
echo -e "$membresPubkeys" | sed 's/ /\n/g' > $WEBPATH/wallets-g1-membres.txt
|
||||||
|
echo -e "$simpleWallets" > $WEBPATH/wallets-g1-simple.txt
|
||||||
|
|
||||||
|
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/_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
|
||||||
|
|
||||||
|
# Export JSON for graph
|
||||||
|
source $SCRIPTPATH/lib/transform_json.sh
|
||||||
|
|
||||||
|
# chown www-data for nginx needs
|
||||||
|
chown -R www-data:www-data $WEBPATH >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
sumSoldes() {
|
||||||
|
sumRWBrut=$(jq -r '.[].rWallets' db/recus.json | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
||||||
|
sumRMBrut=$(jq -r '.[].rMembres' db/recus.json | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
||||||
|
sumRTBrut=$(jq -r '.[] | .rWallets, .rMembres' db/recus.json | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
||||||
|
sumSWBrut=$(jq -r '.[].sWallets' db/recus.json | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
||||||
|
sumSMBrut=$(jq -r '.[].sMembres' db/recus.json | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
||||||
|
sumSTBrut=$(jq -r '.[] | .sWallets, .sMembres' db/recus.json | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
||||||
|
|
||||||
|
soldeWBrut=$(echo "$sumRWBrut-$sumSWBrut" | bc)
|
||||||
|
soldeMBrut=$(echo "$sumRMBrut-$sumSMBrut" | bc)
|
||||||
|
|
||||||
|
sumRW=$(echo $sumRWBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
sumRM=$(echo $sumRMBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
sumRT=$(echo $sumRTBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
sumSW=$(echo $sumSWBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
sumSM=$(echo $sumSMBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
sumST=$(echo $sumSTBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
|
||||||
|
soldeW=$(echo $soldeWBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
soldeM=$(echo $soldeMBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
|
||||||
|
### Calcul de la masse monétaire et du pourcentage de Ḡ1 sur les simples portefeuilles ###
|
||||||
|
monetaryMass=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass)
|
||||||
|
monetaryMassBrut=$(echo "scale=2; ($monetaryMass/100)/1" | bc)
|
||||||
|
monetaryMass=$(echo "$monetaryMassBrut" | tr . , | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
||||||
|
|
||||||
|
pourcentSimpleWallet=$(echo "$soldeWBrut*100/$monetaryMassBrut/1" | bc -l | xargs printf %.1f)
|
||||||
|
|
||||||
|
sleepyG1=$(echo "100-$sumSTBrut*100/$monetaryMassBrut" | bc -l | xargs printf %.1f | tr . ,)
|
||||||
|
}
|
||||||
|
|
||||||
|
nbrWallets() {
|
||||||
|
nbrTotalWallets=$(echo "$wallets" | wc -l)
|
||||||
|
nbrSimpleWallets=$(echo "$nbrTotalWallets-$nbrMembers" | bc)
|
||||||
|
pourcentMbrs=$(echo "$nbrMembers*100/$nbrTotalWallets" | bc -l | xargs printf %.1f)
|
||||||
|
pourcentWallets=$(echo "$nbrSimpleWallets*100/$nbrTotalWallets" | bc -l | xargs printf %.1f)
|
||||||
|
}
|
||||||
|
|
||||||
|
displayStats() {
|
||||||
|
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 -e "\n ---\n"
|
||||||
|
echo "Reçus Wallets: $sumRW"
|
||||||
|
echo "Reçus Membres: $sumRM"
|
||||||
|
echo "Reçus Total: $sumRT"
|
||||||
|
echo -e " ---"
|
||||||
|
echo "Envoyé Wallets: $sumSW"
|
||||||
|
echo "Envoyé Membres: $sumSM"
|
||||||
|
echo "Envoyé Total: $sumST"
|
||||||
|
echo -e " ---"
|
||||||
|
echo "Solde Wallets: $soldeW"
|
||||||
|
echo "Solde Membres: $soldeM"
|
||||||
|
echo -e " ---"
|
||||||
|
echo -e "Masse Monétaire:\t $monetaryMass Ḡ1"
|
||||||
|
echo -e "\n ---\n Analyse\n ---"
|
||||||
|
echo -e "$sleepyG1% des Ḡ1 n'ont jamais été utilisés."
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/bin/bash
|
scanTxWallets() {
|
||||||
|
|
||||||
loopWalletUp() {
|
|
||||||
local REGEX_PUBKEYS="[a-zA-Z0-9]{42,44}"
|
local REGEX_PUBKEYS="[a-zA-Z0-9]{42,44}"
|
||||||
|
|
||||||
# On vérifie le cache existant et on démarre au dernier bloc en cache
|
# On vérifie le cache existant et on démarre au dernier bloc en cache
|
||||||
|
@ -19,22 +17,20 @@ loopWalletUp() {
|
||||||
echo "[" > $SCRIPTPATH/db/recus.json
|
echo "[" > $SCRIPTPATH/db/recus.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv debug.log bk-debug.log-$lastBloc 2>/dev/null #kopa
|
incExec=1
|
||||||
incExec=1 #kopa
|
|
||||||
for i in ${!TXBLOCKS[*]}; do
|
for i in ${!TXBLOCKS[*]}; do
|
||||||
set -x # kopa
|
|
||||||
startExec=$(($(date +%s%N)/1000000))
|
startExec=$(($(date +%s%N)/1000000))
|
||||||
bloc=${TXBLOCKS[$i]}
|
bloc=${TXBLOCKS[$i]}
|
||||||
[[ -z $bloc ]] && break
|
[[ -z $bloc ]] && break
|
||||||
[[ $startIter != 0 && $i -le $startIter ]] && continue
|
[[ $startIter != 0 && $i -le $startIter ]] && continue
|
||||||
# [[ $bloc -lt 5243 ]] && continue #kopa Debug
|
# [[ $bloc -lt 5243 ]] && continue #kopa
|
||||||
sleep 0.05
|
sleep 0.05
|
||||||
|
|
||||||
# Récupère la date et l'objet transaction du bloc courant
|
# Récupère la date et l'objet transaction du bloc courant
|
||||||
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
|
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
|
||||||
#blocFull=$(cat bloc-267)
|
#blocFull=$(cat bloc-267)
|
||||||
until blocBrut=$(echo $blocFull | jq -r '.medianTime, .transactions[]' 2>/dev/null); do
|
until blocBrut=$(echo $blocFull | jq -r '.medianTime, .transactions[]' 2>/dev/null); do
|
||||||
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull" | tee -a debug.log
|
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull"
|
||||||
sleep 2
|
sleep 2
|
||||||
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
|
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
|
||||||
done
|
done
|
||||||
|
@ -63,19 +59,15 @@ loopWalletUp() {
|
||||||
unset recusJson
|
unset recusJson
|
||||||
startBloc=0
|
startBloc=0
|
||||||
fi
|
fi
|
||||||
set +x
|
|
||||||
# Sélectionne les ligne SIG en retirant les issuers
|
# Sélectionne les ligne SIG en retirant les issuers
|
||||||
OIFS="$IFS"
|
OIFS="$IFS"
|
||||||
IFS='{'
|
IFS='{'
|
||||||
echo -e "\n-----------------------------------------\nBloc: $bloc" >> debug.log
|
|
||||||
for j in $walletsReceivedBloc; do
|
for j in $walletsReceivedBloc; do
|
||||||
[[ -z $j ]] && continue
|
[[ -z $j ]] && continue
|
||||||
local wIssuers=$(echo "{$j" | jq -r '.issuers[0]')
|
local wIssuers=$(echo "{$j" | jq -r '.issuers[0]')
|
||||||
local walletsReceivedTodayTmp+=$(echo "{$j" | jq -r '.outputs[]' | grep -v "$wIssuers" | awk -F: '{print $3 "|" $1}' | sed 's/SIG(//g' | tr -d ')')$'\n'
|
local walletsReceivedTodayTmp+=$(echo "{$j" | jq -r '.outputs[]' | grep -v "$wIssuers" | awk -F: '{print $3 "|" $1}' | sed 's/SIG(//g' | tr -d ')')$'\n'
|
||||||
local sumRBloc=$(echo "{$j" | jq -r '.outputs[]' | grep -v "$wIssuers" | awk -F: '{ print $1 }' | awk '{s+=$1} END {print s}')
|
local sumRBloc=$(echo "{$j" | jq -r '.outputs[]' | grep -v "$wIssuers" | awk -F: '{ print $1 }' | awk '{s+=$1} END {print s}')
|
||||||
[[ $sumRBloc ]] && local walletsSentTodayTmp+=$wIssuers'|'$sumRBloc'\n'
|
[[ $sumRBloc ]] && local walletsSentTodayTmp+=$wIssuers'|'$sumRBloc'\n'
|
||||||
echo -e "R: $walletsReceivedTodayTmp\nS: $walletsSentTodayTmp" | grep . >> debug.log
|
|
||||||
echo "---" >> debug.log
|
|
||||||
done
|
done
|
||||||
IFS="$OIFS"
|
IFS="$OIFS"
|
||||||
local walletsSentToday=$(echo -e "$walletsSentTodayTmp" | head -n -1)
|
local walletsSentToday=$(echo -e "$walletsSentTodayTmp" | head -n -1)
|
||||||
|
@ -100,9 +92,6 @@ loopWalletUp() {
|
||||||
if [[ -n $blockDateLast && $blockDateLast != $blockDate ]]; then
|
if [[ -n $blockDateLast && $blockDateLast != $blockDate ]]; then
|
||||||
jsonify
|
jsonify
|
||||||
unset valueReceivedM valueReceivedW valueSentM valueSentW
|
unset valueReceivedM valueReceivedW valueSentM valueSentW
|
||||||
echo -e "Date: $blockDate\n-----------------------------------------\n-----------------------------------------\n" >> debug.log
|
|
||||||
cp debug/xFullDebug.log debug/xFullDebug-$blockDate.log
|
|
||||||
echo "" > debug/xFullDebug.log
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sauvegarde la date de ce bloc pour l'itération suivante
|
# Sauvegarde la date de ce bloc pour l'itération suivante
|
||||||
|
@ -113,7 +102,7 @@ loopWalletUp() {
|
||||||
local pubkey=$(echo $k | awk -F '|' '{ print $1 }')
|
local pubkey=$(echo $k | awk -F '|' '{ print $1 }')
|
||||||
local value=$(echo $k | awk -F '|' '{ print $2 }')
|
local value=$(echo $k | awk -F '|' '{ print $2 }')
|
||||||
|
|
||||||
if [[ $(echo ${MEMBERS[*]} | grep $pubkey) ]]; then
|
if [[ $(echo "$membresPubkeys" | grep $pubkey) ]]; then
|
||||||
valueReceivedM=$(($valueReceivedM+$value))
|
valueReceivedM=$(($valueReceivedM+$value))
|
||||||
pubkeyReceiveM+=${pubkey}\\n
|
pubkeyReceiveM+=${pubkey}\\n
|
||||||
else
|
else
|
||||||
|
@ -127,7 +116,7 @@ loopWalletUp() {
|
||||||
local pubkey=$(echo $k | awk -F '|' '{ print $1 }')
|
local pubkey=$(echo $k | awk -F '|' '{ print $1 }')
|
||||||
local value=$(echo $k | awk -F '|' '{ print $2 }')
|
local value=$(echo $k | awk -F '|' '{ print $2 }')
|
||||||
|
|
||||||
if [[ $(echo ${MEMBERS[*]} | grep $pubkey) ]]; then
|
if [[ $(echo "$membresPubkeys" | grep $pubkey) ]]; then
|
||||||
valueSentM=$(($valueSentM+$value))
|
valueSentM=$(($valueSentM+$value))
|
||||||
pubkeySentM+=${pubkey}\\n
|
pubkeySentM+=${pubkey}\\n
|
||||||
else
|
else
|
||||||
|
@ -141,7 +130,7 @@ loopWalletUp() {
|
||||||
|
|
||||||
# Affiche la progression de la boucle si on est pas en mode web
|
# Affiche la progression de la boucle si on est pas en mode web
|
||||||
progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc)
|
progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc)
|
||||||
endExec=$(($(date +%s%N)/1000000)) #kopa
|
endExec=$(($(date +%s%N)/1000000))
|
||||||
timeExec=$(echo "scale=3; ($endExec-$startExec)/1000" | bc)
|
timeExec=$(echo "scale=3; ($endExec-$startExec)/1000" | bc)
|
||||||
#[[ -z $midTimeExec ]] && midTimeExec=$timeExec
|
#[[ -z $midTimeExec ]] && midTimeExec=$timeExec
|
||||||
[[ $incExec9 == 50 || $incExec == 1 ]] && incExec=1 && midTimeExecCum=0
|
[[ $incExec9 == 50 || $incExec == 1 ]] && incExec=1 && midTimeExecCum=0
|
||||||
|
@ -154,12 +143,12 @@ loopWalletUp() {
|
||||||
echo
|
echo
|
||||||
echo "Scan en cours: $progress% - $bloc/$lastBloc"
|
echo "Scan en cours: $progress% - $bloc/$lastBloc"
|
||||||
echo "Date: $blockDate"
|
echo "Date: $blockDate"
|
||||||
echo "Temps d'execution: $midTimeExec" #kopa
|
echo "Temps d'execution: $midTimeExec"
|
||||||
else
|
else
|
||||||
echo "Scan des blocs avec transactions en cours ..."
|
echo "Scan des blocs avec transactions en cours ..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# [[ $i -ge 10 ]] && break #kopa Debug
|
# [[ $i -ge 10 ]] && break #kopa
|
||||||
done
|
done
|
||||||
|
|
||||||
jsonify
|
jsonify
|
||||||
|
@ -175,102 +164,3 @@ loopWalletUp() {
|
||||||
echo -e "$lastBloc\n$wallets" > $SCRIPTPATH/cache/walletsUp-$i
|
echo -e "$lastBloc\n$wallets" > $SCRIPTPATH/cache/walletsUp-$i
|
||||||
}
|
}
|
||||||
|
|
||||||
loopMembers() {
|
|
||||||
local iter=0
|
|
||||||
for i in ${MEMBERS[*]}; do
|
|
||||||
|
|
||||||
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 "Ajouts des comptes membres sans transaction reçus ... $progress%"
|
|
||||||
else
|
|
||||||
echo "Ajouts des comptes membres sans transaction reçus ..."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $(echo "$wallets" | grep "$i") ]]; then
|
|
||||||
wallets+=$'\n'"$i"
|
|
||||||
fi
|
|
||||||
|
|
||||||
((iter++))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
web() {
|
|
||||||
|
|
||||||
[ ! -d $WEBPATH/history/ ] && mkdir -p $WEBPATH/history/
|
|
||||||
[ ! -d $WEBPATH/graph/ ] && mkdir -p $WEBPATH/graph/
|
|
||||||
[ ! -d $WEBPATH/css ] && cp -r $SCRIPTPATH/tpl/css $WEBPATH/
|
|
||||||
[ ! -d $WEBPATH/js ] && cp -r $SCRIPTPATH/tpl/js $WEBPATH/
|
|
||||||
cp $SCRIPTPATH/tpl/index.html $indexhtml
|
|
||||||
|
|
||||||
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")
|
|
||||||
[[ -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
|
|
||||||
sed -i "s/_nbrSimpleWallets/$nbrSimpleWallets/g" $indexhtml
|
|
||||||
sed -i "s/_nbrMembers/$nbrMembers/g" $indexhtml
|
|
||||||
sed -i "s/_pourcentMbrs/$pourcentMbrs/g" $indexhtml
|
|
||||||
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/_sumRW/$sumRW/g" $indexhtml
|
|
||||||
sed -i "s/_sumSW/$sumSW/g" $indexhtml
|
|
||||||
sed -i "s/_soldeW/$soldeW/g" $indexhtml
|
|
||||||
sed -i "s/_sumRM/$sumRM/g" $indexhtml
|
|
||||||
sed -i "s/_sumSM/$sumSM/g" $indexhtml
|
|
||||||
sed -i "s/_soldeM/$soldeM/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/_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"
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
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/_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
|
|
||||||
|
|
||||||
# Export JSON for graph
|
|
||||||
$SCRIPTPATH/transform_json.sh
|
|
||||||
|
|
||||||
# chown www-data for nginx needs
|
|
||||||
chown -R www-data:www-data $WEBPATH >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
sumSoldes() {
|
|
||||||
sumRWBrut=$(jq -r '.[].rWallets' $1 | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
|
||||||
sumRMBrut=$(jq -r '.[].rMembres' $1 | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
|
||||||
sumRTBrut=$(jq -r '.[] | .rWallets, .rMembres' $1 | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
|
||||||
sumSWBrut=$(jq -r '.[].sWallets' $1 | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
|
||||||
sumSMBrut=$(jq -r '.[].sMembres' $1 | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
|
||||||
sumSTBrut=$(jq -r '.[] | .sWallets, .sMembres' $1 | awk '{ SUM += $1} END { printf "%.2f", SUM }')
|
|
||||||
|
|
||||||
soldeWBrut=$(echo "$sumRWBrut-$sumSWBrut" | bc)
|
|
||||||
soldeMBrut=$(echo "$sumRMBrut-$sumSMBrut" | bc)
|
|
||||||
|
|
||||||
sumRW=$(echo $sumRWBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
sumRM=$(echo $sumRMBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
sumRT=$(echo $sumRTBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
sumSW=$(echo $sumSWBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
sumSM=$(echo $sumSMBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
sumST=$(echo $sumSTBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
|
|
||||||
soldeW=$(echo $soldeWBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
soldeM=$(echo $soldeMBrut | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
|
|
||||||
}
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Varialbes
|
||||||
|
n=2 # Nombre de jours pour les pas en abscisse
|
||||||
|
|
||||||
|
#SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
|
#if [[ -e $SCRIPTPATH/.env ]]; then source $SCRIPTPATH/.env; else echo "Veuillez créer votre fichier .env inspiré de .env.example" && exit 1; fi
|
||||||
|
|
||||||
|
|
||||||
|
## Ḡ1 reçus
|
||||||
|
rWallets() {
|
||||||
|
rWallets=$(grep -E "Date:|Reçus simples wallets|Reçus simples portefeuille|Reçus membres" $WEBPATH/history/index_*.html | awk -F '<b>' '{ print $2 }' | awk '{ print $1 }' | tr -d '.' | tr ',' '.')
|
||||||
|
rWallets=$(sed '/-/i !' <<< $rWallets)
|
||||||
|
|
||||||
|
local j=0
|
||||||
|
local IFS=$'!'
|
||||||
|
for i in $rWallets; do
|
||||||
|
((j++))
|
||||||
|
[[ $j == 1 || ! $(( $j % $n )) == 0 ]] && continue
|
||||||
|
local dateN=$(sed '2q;d' <<< $i)
|
||||||
|
local RW=$(sed '3q;d' <<< $i)
|
||||||
|
local RM=$(sed '4q;d' <<< $i)
|
||||||
|
|
||||||
|
local jsonTPL=$(sed s/_DATE/$dateN/g $SCRIPTPATH/tpl/recus.json)
|
||||||
|
local jsonTPL=$(sed s/_RWALLETS/$RW/g <<< $jsonTPL)
|
||||||
|
local result+=$(sed s/_RMEMBRES/$RM/g <<< $jsonTPL)
|
||||||
|
done
|
||||||
|
|
||||||
|
sed "s/_JSONDATA/$result/g" $SCRIPTPATH/tpl/recus.html > $WEBPATH/graph/recus.html
|
||||||
|
sed "s/_JSONDATARW/$result/g" $SCRIPTPATH/tpl/mixed.html > $WEBPATH/graph/mixed.html
|
||||||
|
}
|
||||||
|
|
||||||
|
nbrWallets() {
|
||||||
|
## Nombre de wallets
|
||||||
|
nbrWallets=$(grep -E "Date:|Nombre de membres|Nombre de simple portefeuille" $WEBPATH/history/index_*.html | awk -F '<b>' '{ print $2 }' | awk -F '</b>' '{ print $1 }' | awk '{ print $1 }')
|
||||||
|
nbrWallets=$(sed '/-/i !' <<< $nbrWallets)
|
||||||
|
|
||||||
|
local j=0
|
||||||
|
local IFS=$'!'
|
||||||
|
for i in $nbrWallets; do
|
||||||
|
((j++))
|
||||||
|
[[ $j == 1 || ! $(( $j % $n )) == 0 ]] && continue
|
||||||
|
local dateN=$(sed '2q;d' <<< $i)
|
||||||
|
local NBRM=$(sed '3q;d' <<< $i)
|
||||||
|
local NBRW=$(sed '4q;d' <<< $i)
|
||||||
|
|
||||||
|
local jsonTPL=$(sed s/_DATE/$dateN/g $SCRIPTPATH/tpl/nbr_wallets.json)
|
||||||
|
local jsonTPL=$(sed s/_NBRWALLETS/$NBRW/g <<< $jsonTPL)
|
||||||
|
local result+=$(sed s/_NBRMEMBRES/$NBRM/g <<< $jsonTPL)
|
||||||
|
done
|
||||||
|
|
||||||
|
sed "s/_JSONDATA/$result/g" $SCRIPTPATH/tpl/nbr_wallets.html > $WEBPATH/graph/nbr_wallets.html
|
||||||
|
sed -i "s/_JSONDATANBRW/$result/g" $WEBPATH/graph/mixed.html
|
||||||
|
}
|
||||||
|
|
||||||
|
rWallets
|
||||||
|
nbrWallets
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cacheFile=$(ls cache/bk-walletsUp-* | tail -n1)
|
|
||||||
cacheID=$(echo $cacheFile | awk -F '-' '{ print $NF }')
|
|
||||||
|
|
||||||
cp $cacheFile cache/walletsUp-$cacheID
|
|
||||||
cp db/bk-recus.json-$cacheID db/recus.json
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
|
|
||||||
|
cacheFile=$(ls $SCRIPTPATH/../cache/walletsUp-*)
|
||||||
|
cacheID=$(echo $cacheFile | awk -F '-' '{ print $NF }')
|
||||||
|
|
||||||
|
#rm -f cache/bk-walletsUp-*
|
||||||
|
cp $cacheFile $SCRIPTPATH/../cache/bk-walletsUp-$cacheID
|
||||||
|
cp $SCRIPTPATH/../db/recus.json $SCRIPTPATH/../db/bk-recus.json-$cacheID
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
|
|
||||||
|
jq -r '.[] | "---", .date, .rWallets + .rMembres' $SCRIPTPATH/../db/recus.json > $SCRIPTPATH/../db/somme.txt
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
|
|
||||||
|
cacheFile=$(ls $SCRIPTPATH/../cache/bk-walletsUp-* | tail -n1)
|
||||||
|
cacheID=$(echo $cacheFile | awk -F '-' '{ print $NF }')
|
||||||
|
|
||||||
|
cp $cacheFile $SCRIPTPATH/../cache/walletsUp-$cacheID
|
||||||
|
cp $SCRIPTPATH/../db/bk-recus.json-$cacheID $SCRIPTPATH/../db/recus.json
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Varialbes
|
|
||||||
n=2 # Nombre de jours pour les pas en abscisse
|
|
||||||
|
|
||||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
|
||||||
if [[ -e $SCRIPTPATH/.env ]]; then source $SCRIPTPATH/.env; else echo "Veuillez créer votre fichier .env inspiré de .env.example" && exit 1; fi
|
|
||||||
|
|
||||||
|
|
||||||
## Ḡ1 reçus
|
|
||||||
rWallets() {
|
|
||||||
rWallets=$(grep -E "Date:|Reçus simples wallets|Reçus simples portefeuille|Reçus membres" $WEBPATH/history/index_*.html | awk -F '<b>' '{ print $2 }' | awk '{ print $1 }' | tr -d '.' | tr ',' '.')
|
|
||||||
rWallets=$(sed '/-/i !' <<< $rWallets)
|
|
||||||
|
|
||||||
local j=0
|
|
||||||
local IFS=$'!'
|
|
||||||
for i in $rWallets; do
|
|
||||||
((j++))
|
|
||||||
[[ $j == 1 || ! $(( $j % $n )) == 0 ]] && continue
|
|
||||||
local dateN=$(sed '2q;d' <<< $i)
|
|
||||||
local RW=$(sed '3q;d' <<< $i)
|
|
||||||
local RM=$(sed '4q;d' <<< $i)
|
|
||||||
|
|
||||||
local jsonTPL=$(sed s/_DATE/$dateN/g $SCRIPTPATH/tpl/recus.json)
|
|
||||||
local jsonTPL=$(sed s/_RWALLETS/$RW/g <<< $jsonTPL)
|
|
||||||
local result+=$(sed s/_RMEMBRES/$RM/g <<< $jsonTPL)
|
|
||||||
done
|
|
||||||
|
|
||||||
sed "s/_JSONDATA/$result/g" $SCRIPTPATH/tpl/recus.html > $WEBPATH/graph/recus.html
|
|
||||||
sed "s/_JSONDATARW/$result/g" $SCRIPTPATH/tpl/mixed.html > $WEBPATH/graph/mixed.html
|
|
||||||
}
|
|
||||||
|
|
||||||
nbrWallets() {
|
|
||||||
## Nombre de wallets
|
|
||||||
nbrWallets=$(grep -E "Date:|Nombre de membres|Nombre de simple portefeuille" $WEBPATH/history/index_*.html | awk -F '<b>' '{ print $2 }' | awk -F '</b>' '{ print $1 }' | awk '{ print $1 }')
|
|
||||||
nbrWallets=$(sed '/-/i !' <<< $nbrWallets)
|
|
||||||
|
|
||||||
local j=0
|
|
||||||
local IFS=$'!'
|
|
||||||
for i in $nbrWallets; do
|
|
||||||
((j++))
|
|
||||||
[[ $j == 1 || ! $(( $j % $n )) == 0 ]] && continue
|
|
||||||
local dateN=$(sed '2q;d' <<< $i)
|
|
||||||
local NBRM=$(sed '3q;d' <<< $i)
|
|
||||||
local NBRW=$(sed '4q;d' <<< $i)
|
|
||||||
|
|
||||||
local jsonTPL=$(sed s/_DATE/$dateN/g $SCRIPTPATH/tpl/nbr_wallets.json)
|
|
||||||
local jsonTPL=$(sed s/_NBRWALLETS/$NBRW/g <<< $jsonTPL)
|
|
||||||
local result+=$(sed s/_NBRMEMBRES/$NBRM/g <<< $jsonTPL)
|
|
||||||
done
|
|
||||||
|
|
||||||
sed "s/_JSONDATA/$result/g" $SCRIPTPATH/tpl/nbr_wallets.html > $WEBPATH/graph/nbr_wallets.html
|
|
||||||
sed -i "s/_JSONDATANBRW/$result/g" $WEBPATH/graph/mixed.html
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
rWallets
|
|
||||||
nbrWallets
|
|
Loading…
Reference in New Issue