Compare commits

..

No commits in common. "master" and "old-nonJSON-version" have entirely different histories.

34 changed files with 457 additions and 1379 deletions

View File

@ -1,4 +1,5 @@
DUNITER="https://duniter-g1.p2p.legal" # Adresse du noeud Duniter qui sera scanné
ESNODE="http://g1.data.duniter.fr" # Adresse du noeud ElasticSearch qui sera scanné (Si nécessaire)
WEBPATH="/var/www/g1-stats" # Dossier qui sera créé si vous choisissez l'option web pour la mise en ligne des données (nécessite une configuration apache ou nginx)
SILKAJ="" # Chemin vers Silkaj (Récupéré automatiquement si non renseigné)
DUNITER="https://duniter-g1.p2p.legal" # Adresse du noeud Duniter qui sera scanné
DUNITER2="https://g1.duniter.org" # Seconde adresse par sécurité
DUNITER3="https://duniter.g1.1000i100.fr" # Troisième adresse par sécurité
ESNODE="http://g1.data.duniter.fr" # Adresse du noeud ElasticSearch qui sera scanné
WEBPATH="/var/www/g1-stats" # Dossier qui sera créé si vous choisissez l'option web pour la mise en ligne des données (nécessite une configuration apache ou nginx)

7
.gitignore vendored
View File

@ -1,10 +1,3 @@
.env
renameHistory.sh
db/*
cache
debug.log
bk-debug.log
bk
.gitPushToMaster.sh
walletsBalance.log

View File

@ -1,68 +1,27 @@
# Indexation de la blockchain Duniter/Ḡ1
## Sous forme d'un fichier JSON journalisé et d'outils d'exploitation de ce JSON
# Extraction de quelques chiffres liés à la ḡ1
### Visible sur: [https://g1-stats.axiom-team.fr/](https://g1-stats.axiom-team.fr/)
Utilise l'[API BMA](https://github.com/duniter/duniter-bma/blob/master/doc/API.md) pour l'extraction et l'indexation des données de la [blockchain Duniter/Ḡ1](https://duniter.org).<br>
*Ce code n'a pas été testé dans un autre environement que le miens (Debian 10), il est publié par simple soucis de transparence et d'audit*
Utilise l'API BMA pour l'extraction des clés publiques ḡ1 membres et non membres, ainsi que l'API ElasticSearch de Cesium+ pour la récupération des soldes par soucis d'optimisation.
A exécuter dans un environnement Bash Debian/Ubuntu.
*Si vous souhaitez modifier les paramètres par defaut, copiez le fichier .env.example en .env et adaptez les variables selon votre usage.*
## Prérequis
Copiez le fichier .env.example en .env et adaptez les variables selon votre usage.
## Exécution
Lancer le scan ainsi que tout le processus d'indexation depuis le début de la blockchain jusqu'à aujourd'hui
```
./g1-stats.sh
```
*A la première execution, ce scan peut durer plusieurs heures!*<br>
Pour pourrez suivre la progression du scan en temps réel.<br>
Pour les exécutions ultérieures, un cache est géneré permettant de reprendre le scan là où il s'est arrêté, diminuant drastiquement le temps d'execution.
Le fichier JSON est alors généré: `db/daily.json`
`./g1-stats.sh`
Pour générer la page web static:
```
./g1-stats.sh web
```
## Exploration
Une fois le fichier JSON correctement généré, vous pouvez utiliser `explorer.sh` pour l'exploiter.<br>
Pour obtenir l'aide:
```
./explorer.sh -h
```
**Ce script explorer.sh fonctionne de manière standalone, c'est à dire que vous pouvez l'utiliser en dehors de l'environnement Ḡ1Stats sans aucune dépendance:**
```
wget https://git.p2p.legal/axiom-team/g1-stats/raw/master/explorer.sh
chmod u+x explorer.sh
```
## Sauvegarde/Restauration
Un script de sauvegarde se trouve dans le dossier `scripts`:
```
./scripts/backup-cache.sh
```
Permettant le faire une copie de votre fichier json actuel ainsi que du cache qui lui correspond
Pour restaurer le backup le plus récent:
```
./scripts/restore-cache.sh
```
Pour restaurer un backup à partir d'un bloc précis, par exemple le bloc 4242 (le numéro du bloc se trouve dans le nom du backup du cache):
```
./scripts/restore-cache.sh 4242
```
`./g1-stats.sh web`
## Automatisation
Vous pouvez décider d'exécuter ce script régulièrement grâce à une tache cron.<br>
Vous pouvez décider d'exécuter ce script régulièrement grâce à une tache cron.
Par exemple pour l'exécuter toutes les 3 heures:
```
TERM=xterm # Nécessaire pour la gestion tput des sorties log
0 */3 * * * /path/to/script/g1-stats.sh web >> /var/log/g1-stats.log 2>&1
```
`echo "0 */3 * * * /path/to/script/g1-stats.sh web >> /var/log/g1-stats.log 2>&1" >> /var/spool/cron/crontabs/$USER`

View File

@ -1,149 +0,0 @@
#!/bin/bash
################################################################################
# Author: Poka (poka@p2p.legal)
# Version: 0.0.3
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
# Git: https://git.p2p.legal/axiom-team/g1-stats
################################################################################
###
# Please change this path if needed, in relative path from explorer.sh script
# If no file found, then this script will download it from https://g1-stats.axiom-team.fr and prompt it
jsonFile="db/daily.json"
###
# Check if jq, jo and curl are installed, or install them
[[ -z $(which jq) || -z $(which jo) || -z $(which curl) ]] && sudo apt update && sudo apt install jq jo bc curl -y
# Path of the current script
GPATH="$( cd "$(dirname "$0")" ; pwd -P )"
jsonFile="$GPATH/$jsonFile"
if [[ -f $jsonFile ]]; then
jsonData=$(cat $jsonFile)
else
echo "Warning: No JSON file found, we download it from https://g1-stats.axiom-team.fr/data/daily.json" >&2
jsonData="$(curl -s https://g1-stats.axiom-team.fr/data/daily.json)"
fi
# Help display
helpOpt() {
echo -e "Welcome to Ḡ1Stats Explorer V$(head $0 | awk '/# Version:/ { print $3 }')
\rThis tool can be use in 2 differents mode:
\r- Isolate mode (default): Display data of a selected day
\r- Cumulative mode (option -c or --cumulate): Display cumulative data from begining of Ḡ1 Blockchain (08-03-17) until selected day
\rExamples:
\r$0
Default view show last day data in cumulative mode
\r$0 day 08-03-20
Display 8th Mars 2020's data
\r$0 day 08-03-20 -c
Display 8th Mars 2020's cumulative data from begining
\r$0 mass -c [day]
Display monetary mass on current day, or selected day
\r$0 solde [day]
Display solde (Received - Sent) for simple wallets and members wallets on a day
\r$0 total [day]
Display Sent and Received Ḡ1 in total on a day
\r$0 custom \".rMembers==0 and .sMembers==0\"
Display custom filter. Here we get only days where members received and sent nothing
\r$0 anniversary -c
Display UD reassessment days, the new UD value and the number of members this day"
}
jqCumulate="def roundit: (.*100.0)+ 0.5|floor/100.0;
[foreach .[] as \$row (null;
.nbrMembers += \$row.nbrMembers |
.nbrWallets += \$row.nbrWallets |
.sMembers = (\$row.sMembers + .sMembers|roundit) |
.rMembers = (\$row.rMembers + .rMembers|roundit) |
.sWallets = (\$row.sWallets + .sWallets|roundit) |
.rWallets = (\$row.rWallets + .rWallets|roundit);
\$row + . )]"
# Parse options
for i in $@; do
case "$i" in
-c|--cumulate) jsonData="$(jq "$jqCumulate" <<<$jsonData)";;
-h|--help) helpOpt && exit 0;;
*) isArg+="$i|";;
esac
done
# Load arguments in respective variables
cmd=$(cut -d'|' -f1 <<<"$isArg")
dateRange=$(cut -d'|' -f2 <<<"$isArg")
args="$(cut -d'|' -f2- <<<"$isArg" | sed 's/.$//' | tr '|' ' ')"
# If no date, set last available
[[ -z "$dateRange" ]] && dateRange=$(jq -r '.[].date' <<<$jsonData | tail -n1)
# Check if date existe un JSON
[[ ! $(grep -w "$dateRange" <<<$jsonData) && $cmd != "custom" ]] && echo "La date $dateRange n'existe pas en cache G1Stats" && exit 1
day() {
jq '.[] | select(.date=="'$dateRange'")' <<<$jsonData
}
mass() {
local jsonDated=$(jq '.[0: map(.date) | index("'$dateRange'")+1]' <<<$jsonData)
local mMass=$(jq '.[] | .UD*.nbrMembers' <<<"$jsonDated" | awk '{ SUM += $1} END { printf "%.2f", SUM }')
jo -p date=$dateRange monetaryMass=$mMass | jq .
}
total() {
local cumDay=$(day)
local totalExchange=$(jq '(.rWallets+.rMembers)*100.0+ 0.5|floor/100.0' <<<$cumDay)
local soldeWallets=$(jq '(.rWallets-.sWallets)*100.0+ 0.5|floor/100.0' <<<$cumDay)
local soldeMembers=$(jq '(.rMembers-.sMembers)*100.0+ 0.5|floor/100.0' <<<$cumDay)
jo -p date=$dateRange totalExchange=$totalExchange soldeWallets=$soldeWallets soldeMembers=$soldeMembers | jq .
}
totall() {
for i in $(jq -r .[].date <<<$jsonData); do
dateRange=$i
total
done
}
custom() {
jq '.[] | select('"$args"')' <<<$jsonData
}
anniversary() {
local jqNewUD="reduce .[] as \$x (null;
if . == null then [\$x]
elif .[-1].UD == \$x.UD then .
else . + [\$x] end) | .[] |=
{date: .date, UD: .UD, nbrMembers: .nbrMembers}"
jq "$jqNewUD" <<<$jsonData
}
today() {
todayDate=$(date +'%d-%m-%y')
jq '.[] | select(.date=="'$todayDate'")' <<<$jsonData
}
update() {
curl -s https://g1-stats.axiom-team.fr/data/daily.json > $jsonFile && echo "Data have been updated" || echo "Error: Can't update data"
}
print() {
jq . <<<"$jsonData"
}
# Load functions
case $cmd in
'') day;;
solde) total;;
*) [[ $(type -t $cmd) == "function" ]] && $cmd || (echo -e "$cmd: Commande inconnue\n" && helpOpt);;
esac

View File

@ -2,73 +2,261 @@
################################################################################
# Author: Poka (poka@p2p.legal)
# Version: 0.3.0
# Version: 0.1.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
# Git: https://git.p2p.legal/axiom-team/g1-stats
################################################################################
[[ -z $debug ]] && debug=false
# Exit script if error
set -e
# Récupération du chemin absolu du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )"
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
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
### Initialisation des données ###
startTime=$(date +'%H:%M')
day=$(date +'%y-%m-%d')
dayP=$(date +'%d-%m-%y')
indexhtml="$WEBPATH/index.html"
echo -e "\n############# $day à $startTime #############\n"
[[ -z $(which jq) || -z $(which jo) || -z $(which bc) || -z $(which curl) ]] && sudo apt update && sudo apt install jq jo bc curl -y
[[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc
echo "Initialisation ..."
if $debug; then
TXBLOCKS=$(cat $GPATH/db/debug/txblocs)
membresPubkeys=$(cat $GPATH/db/debug/membresPubkeys)
udBlocs=$(cat $GPATH/db/debug/udblocs)
echo # To clean next progress view
else
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
# TXBLOCKS=$(cat $GPATH/tx.json | jq '.result.blocks[]')
echo "TXBLOCKS OK"
membresPubkeys=$(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')
tput cuu1;tput el;
echo "membresPubkeys OK"
udBlocs=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]')
tput cuu1;tput el;
echo "udBlocs OK"
fi
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
nbrMembers=$(echo "$membresPubkeys" | wc -l)
unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]'
MEMBERS=($(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey'))
nbrMembers=${#MEMBERS[@]}
lastBloc=${TXBLOCKS[-1]}
isWeb=$1
jsonFile="$GPATH/db/daily.json"
### On source les fonctions
source $GPATH/lib/functions.sh
source $GPATH/lib/scanTxWallets.sh
### Extraction des adresses Ḡ1 actives ###
### Extraction des adresses Ḡ1 actives
scanTxWallets
### Calcul la somme des soldes portefeuilles et membres
sumSoldes
loopWalletUp() {
local iter=0
local REGEX_PUBKEYS="[a-zA-Z0-9]{42,44}"
### Ajout des membres sans transaction
addMembers
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
### Calcul du nombre de wallets
nbrWallets
for i in ${TXBLOCKS[*]:$startBloc}; do # pour tout n° de bloc listé dans TXBLOCKS
sleep 0.05
local WALLETS0=$(curl -s ${DUNITER}/blockchain/block/$i)
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
### Affichage des stats
displayStats
[[ -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)
if [[ $isWeb != "web" ]]; then
clear
echo "Heure de début: $startTime"
echo
echo "Scan en cours: $progress% - $i/$lastBloc"
fi
((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
### Ajout des membres sans transaction au fichier tampon ###
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 "Scan en cours: 100% - $lastBloc/$lastBloc"
echo "Ajouts des comptes membres ... $progress%"
fi
fi
if [[ -z $(echo "$wallets" | grep "$i") ]]; then
wallets+=$'\n'"$i"
fi
((iter++))
done
}
loopMembers
### 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)
### Renseignement de l'index web et indexation de l'historique ###
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
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
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
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/_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/_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-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
# Export JSON for graph
$SCRIPTPATH/transform_json.sh
# chown www-data for nginx needs
chown -R www-data:www-data $WEBPATH
}
### 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 -e "\n ---\n"
echo "Extraction wallets membres / Simples portefeuille"
echo -e "\n ---\n"
### Isolation des simples portefeuilles ###
simpleWallets="$wallets"
echo "Isolation des simples portefeuilles..."
for i in ${MEMBERS[@]}; do
simpleWallets=$(echo "$simpleWallets" | grep -v "$i")
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 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
}
echo "Récupération du solde des simples wallets..."
pubkeys=$simpleWallets
getSolde
txInSimple=$(echo $txInT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
txOutSimple=$(echo $txOutT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
soldeSimpleBrut=$(echo $solde)
soldeSimple=$(echo $soldeSimpleBrut | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
echo -e "Reçus simples wallets:\t $txInSimple"
echo -e "Envoyé simples wallets:\t $txOutSimple"
echo -e "Soldes simples wallets:\t $soldeSimple"
echo -e "\n ---\n"
echo "Récupération du solde des membres..."
pubkeys=${MEMBERS[@]}
getSolde
txInMembers=$(echo $txInT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
txOutMembers=$(echo $txOutT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
soldeMembersBrut=$(echo $solde)
soldeMembers=$(echo $soldeMembersBrut | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
echo -e "Reçus membres:\t $txInMembers"
echo -e "Envoyé membres:\t $txOutMembers"
echo -e "Soldes membres:\t $soldeMembers"
echo -e "Total DU non consumés:\t $nonConsumedUDT"
### 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; $soldeMembersBrut+$soldeSimpleBrut" | bc | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
pourcentSimpleWallet=$(echo "scale=1; $soldeSimpleBrut*100/$monetaryMassBrut/1" | bc)
echo -e "\n ---\n"
echo -e "Solde des membres (sans DU):\t $soldeWalletMembers"
echo -e "Masse Monétaire:\t $monetaryMass Ḡ1"
# Analyse
echo -e "\n ---\n Analyse\n ---\n"
sleepyG1=$(echo -e "scale=1; 100-$txOutT*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
[[ $isWeb == "web" ]] && web
### Fin de programme
### Fin de programme ###
day=$(date +'%d-%m-%y')
echo "
---
$day - Heure de fin: $(date +'%H:%M')"
echo "$day - Heure de fin: $(date +'%H:%M')"

View File

@ -1,152 +0,0 @@
#!/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..."
# On split la listes des wallets pour ne pas saturer grep
local id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
local tmpSplit="/tmp/g1stats-splits-$id"
mkdir -p $tmpSplit
pushd $tmpSplit >/dev/null || exit 1
split -d -l 2500 <<<"$membresPubkeys"
simpleWallets="$wallets"
for i in $(ls x*); do
local walletToSup=$(cat $i)
simpleWallets=$(echo "$simpleWallets" | grep -vF "$walletToSup")
done
[[ -d $tmpSplit ]] && rm -r $tmpSplit || exit 1
popd >/dev/null
}
web() {
[ ! -d $WEBPATH/history/ ] && mkdir -p $WEBPATH/history/
[ ! -d $WEBPATH/graph/ ] && mkdir -p $WEBPATH/graph/
[ ! -d $WEBPATH/data/ ] && mkdir -p $WEBPATH/data/
[ ! -d $WEBPATH/css ] && cp -r $GPATH/tpl/css $WEBPATH/
[ ! -d $WEBPATH/js ] && cp -r $GPATH/tpl/js $WEBPATH/
indexhtml="$WEBPATH/index.html"
cp $GPATH/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/data/wallets-g1.txt
echo -e "$membresPubkeys" | sed 's/ /\n/g' > $WEBPATH/data/wallets-g1-membres.txt
echo -e "$simpleWallets" > $WEBPATH/data/wallets-g1-simple.txt
cp $GPATH/db/daily.json $WEBPATH/data/
$GPATH/explorer.sh print -c > $WEBPATH/data/cum-daily.json
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-team.svg/..\/logo-axiom-team.svg/g" $WEBPATH/history/index_$day.html
sed -i 's/id="charts">/id="charts" style="display:none;">/g' $WEBPATH/history/index_$day.html
sed -i '/href="css\/charts.css"/d' $WEBPATH/history/index_$day.html
sed -i '/type="text\/javascript"/d' $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
# chown www-data for nginx needs
chown -R www-data:www-data $WEBPATH >/dev/null 2>&1
}
sumSoldes() {
source $GPATH/explorer.sh -c > /dev/null
sumRW=$(day | jq '.rWallets' | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
sumRM=$(day | jq '.rMembers' | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
sumRT=$(total | jq '.totalExchange' | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
sumSW=$(day | jq '.sWallets' | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
sumSM=$(day | jq '.sMembers' | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
sumSTBrut=$(total | jq '.totalExchange')
sumST=$(sed ':a;s/\B[0-9]\{3\}\>/ &/;ta' <<<"$sumSTBrut")
soldeWBrut=$(total | jq '.soldeWallets')
soldeW=$(sed ':a;s/\B[0-9]\{3\}\>/ &/;ta' <<<"$soldeWBrut")
soldeM=$(total | jq '.soldeMembers' | sed ':a;s/\B[0-9]\{3\}\>/ &/;ta')
### Calcul de la masse monétaire et du pourcentage de Ḡ1 sur les simples portefeuilles
monetaryMassBrut=$(mass | jq .monetaryMass)
monetaryMass=$(echo "$monetaryMassBrut" | 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)
}
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 "
---
Noeud: $DUNITER
Nombre total de wallet: $nbrTotalWallets
Nombre de membres: $nbrMembers (${pourcentMbrs}%)
Nombre de simple portefeuille: $nbrSimpleWallets (${pourcentWallets}%)
---
Reçus Wallets: $sumRW
Reçus Membres: $sumRM
Reçus Total: $sumRT
---
Envoyé Wallets: $sumSW
Envoyé Membres: $sumSM
Envoyé Total: $sumST
---
Solde Wallets: $soldeW
Solde Membres: $soldeM
---
Masse Monétaire: $monetaryMass Ḡ1
---
Analyse
---
$sleepyG1% des Ḡ1 n'ont jamais été utilisés."
}
rmOldCache() {
keepCache=20
listCache=$(ls -l $GPATH/db/bk-* | awk '{ print $9 }')
listID=$(echo "$listCache" | awk -F '-' '{ print $NF }')
nbrID=$(echo "$listID" | wc -l)
nbrToSup=$((nbrID-$keepCache))
if [[ $nbrToSup -ge 0 ]]; then
cacheIDToSup=$(echo "$listID" | head -n$nbrToSup)
for i in $cacheIDToSup; do
rm $GPATH/db/bk-daily.json-$i
rm $GPATH/cache/bk-walletsUp-$i
done
fi
}

View File

@ -1,278 +0,0 @@
#!/bin/bash
scanTxWallets() {
local REGEX_PUBKEYS="[a-zA-Z0-9]{42,44}"
# On vérifie le cache existant et on démarre au dernier bloc en cache
if ls $GPATH/cache/walletsUp-* > /dev/null 2>&1; then
local startFile=$(ls $GPATH/cache/walletsUp-* | tail -n1)
local startIter=$(echo "$startFile" | awk -F '-' '{ print $NF }')
((startIter++))
local startBloc=$(head -n1 "$startFile")
wallets=$(tail -n +2 "$startFile" | sed '/---/Q' | sort -u)
local walletsAuj=$(cat "$startFile" | sed -e '1,/---/d' | sed '/---/Q' | grep .)$'\n'
local nbrMembersYesterday=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 1)
local blockDateLast=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 2)
local nbrDays=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 3)
#! ($debug) &&
[[ $lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]} ]] && echo "$lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]}" && return
rm $startFile
else
local startIter=0
local startBloc=0
local nbrDays=1
echo "[" > $jsonFile
fi
incExec=1
for ((i=$startIter; i<${#TXBLOCKS[@]}; i++)); do
local nbrIteration=$i
local startExec=$(($(date +%s%N)/1000000))
local bloc=${TXBLOCKS[$i]}
[[ -z $bloc ]] && break
# [[ $i -lt 1190 ]] && continue #kopa
# Récupération du bloc courant
local blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
while [[ $(jq -r '.ucode' <<<"$blocFull") == 1006 ]]; do
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull"
sleep 2
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
done
until blocBrut=$(jq -r '.' <<<"$blocFull" 2>/dev/null); do
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull"
sleep 2
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
done
[[ -z "$blocBrut" ]] && continue
echo "$blocFull" > debugTmp.txt
echo "-----------------------------------" >> debugTmp.txt
echo "$blocBrut" >> debugTmp.txt
# Récupération de la date du block
local blockDate=$(jq '.medianTime' <<<"$blocBrut")
#kopa echo "$blocBrut"
# echo "---"
# echo "$blockDate"
blockDate=$(date -d"@$blockDate" +%d-%m-%y -u)
local walletsReceivedBloc=$(jq '.transactions[]' <<<"$blocBrut")
# Si cette itération provient d'un cache, alors on aggrège la dernière date
if [[ $startBloc != 0 ]]; then
local lastDate=$(jq -r '.[].date' $jsonFile | tail -n1)
if [[ "$blockDate" == "$lastDate" || (-n $blockDateLast && $blockDateLast != $blockDate) ]]; then
local valueReceivedW=$(jq -r '.[].rWallets' $jsonFile | tail -n1 | xargs echo 100* | bc)
local valueReceivedM=$(jq -r '.[].rMembers' $jsonFile | tail -n1 | xargs echo 100* | bc)
local valueSentW=$(jq -r '.[].sWallets' $jsonFile | tail -n1 | xargs echo 100* | bc)
local valueSentM=$(jq -r '.[].sMembers' $jsonFile | tail -n1 | xargs echo 100* | bc)
local recusJson=$(head -n -11 $jsonFile)
echo "$recusJson" > $jsonFile
else
local recusJson=$(head -n -2 $jsonFile)
echo -e "$recusJson\n }," > $jsonFile
fi
startBloc=0
fi
# Sélectionne les ligne SIG en retirant les issuers
OIFS="$IFS"
IFS='{'
for j in $walletsReceivedBloc; do
[[ -z $j ]] && continue
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 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'
done
IFS="$OIFS"
local walletsSentToday=$(echo -e "$walletsSentTodayTmp" | head -n -1)
local walletsReceivedBloc=$(echo -e "$walletsReceivedTodayTmp" | head -n -1)
unset walletsReceivedTodayTmp walletsSentTodayTmp
[[ -z $walletsReceivedBloc ]] && continue
# Stock les clés publiques de ce bloc dans la variable $wallets
walletsAuj+=$(echo "$walletsReceivedBloc" | grep -Eo $REGEX_PUBKEYS)$'\n'
# Exporte les valeurs de la journée dans le fichier JSON
jsonify() {
[[ -z $valueReceivedW ]] && valueReceivedW=0 || valueReceivedW=$(echo "scale=2; $valueReceivedW/100" | bc | awk '{ printf("%.2f\n", $0); }')
[[ -z $valueReceivedM ]] && valueReceivedM=0 || valueReceivedM=$(echo "scale=2; $valueReceivedM/100" | bc | awk '{ printf("%.2f\n", $0); }')
[[ -z $valueSentM ]] && valueSentM=0 || valueSentM=$(echo "scale=2; $valueSentM/100" | bc | awk '{ printf("%.2f\n", $0); }')
[[ -z $valueSentW ]] && valueSentW=0 || valueSentW=$(echo "scale=2; $valueSentW/100" | bc | awk '{ printf("%.2f\n", $0); }')
[[ -z $nbrMembersToday ]] && nbrMembersToday=0
[[ -z $nbrWallets ]] && nbrWallets=0
[[ -z $UDToday ]] && UDToday=0
local jsonTPL=$(sed s/_DATE/$blockDateLast/g $GPATH/tpl/daily.json)
jsonTPL=$(sed s/_UDTODAY/$UDToday/g <<< $jsonTPL)
jsonTPL=$(sed s/_RWALLETS/$valueReceivedW/g <<< $jsonTPL)
jsonTPL=$(sed s/_SWALLETS/$valueSentW/g <<< $jsonTPL)
jsonTPL=$(sed s/_RMEMBERS/$valueReceivedM/g <<< $jsonTPL)
jsonTPL=$(sed s/_SMEMBERS/$valueSentM/g <<< $jsonTPL)
jsonTPL=$(sed s/_NBRMEMBERS/$nbrMembersToday/g <<< $jsonTPL)
jsonTPL=$(sed s/_NBRWALLETS/$nbrWallets/g <<< $jsonTPL)
echo -e "$jsonTPL" | tr -d '\\' >> $jsonFile
}
# Si la date du bloc courant est différente du bloc précedent, alors on stock les valeurs journalières
applyToday() {
[[ -z $wallets ]] && wallets="#"
local WALLETS=$(echo -e "$wallets" | grep .)
# On split la liste des wallets pour ne pas saturer grep
local id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
local tmpSplit="/tmp/g1stats-splits-$id"
mkdir -p $tmpSplit
pushd $tmpSplit >/dev/null || exit 1
echo -e "$membresPubkeys\n$WALLETS" | split -d -l 2500
local walletsAujTmp=$(echo -e "$walletsAuj" | sort -u | awk 'NF')
local i
for i in $(ls x*); do
local walletToSup=$(cat $i)
local walletsAujTmp=$(echo "$walletsAujTmp" | grep -vF "$walletToSup")
done
[[ -d $tmpSplit ]] && rm -r $tmpSplit || exit 1
popd >/dev/null
nbrWallets=$(echo "$walletsAujTmp" | wc -l)
unset walletsAujTmp
# Obtention du dividende à ce block
lastUdBloc=$(head -n$nbrDays <<<"$udBlocs" | tail -n1)
[[ -z $lastUdBloc ]] && lastUdBloc=$(echo "$udBlocs" | tail -n1)
local blocUD=$(curl -s ${DUNITER}/blockchain/block/$lastUdBloc | jq '.membersCount,.dividend')
UDToday=$(echo "$blocUD" | tail -n1 | xargs -i echo "scale=2; {}/100" | bc)
# Calcul du nombre de nouveaux membres à ce block
nbrMembersTotalToday=$(echo "$blocUD" | head -n1)
[[ -z $nbrMembersYesterday ]] && nbrMembersYesterday=0
nbrMembersToday=$(($nbrMembersTotalToday-$nbrMembersYesterday))
jsonify
# Mise en cache périodique
## On supprime les doublons et les lignes vides
wallets=$(echo -e "$wallets" | sort -u | awk 'NF')
# if ((i % 50 == 0)); then #kopaa
echo -e "$bloc\n$wallets\n---\n$walletsAuj\n---\n$nbrMembersYesterday|$blockDateLast|$nbrDays" > $GPATH/cache/bk-walletsUp-$nbrIteration
cp $GPATH/db/daily.json $GPATH/db/bk-daily.json-$nbrIteration
## Retire la dernière virgule et ajoute le crochet de fin de JSON
sed -i '$ s/,//g' $GPATH/db/bk-daily.json-$nbrIteration
echo "]" >> $GPATH/db/bk-daily.json-$nbrIteration
## On supprime le vieux cache
rmOldCache
# fi
}
if [[ -n $blockDateLast && $blockDateLast != $blockDate ]]; then
applyToday
[[ $wallets == "#" ]] && unset wallets
wallets+=$'\n'"$walletsAuj"
wallets=$(echo -e "$wallets" | sort -u | grep .)$'\n'
nbrMembersYesterday=$nbrMembersTotalToday
unset valueReceivedM valueReceivedW valueSentM valueSentW walletsAuj nbrMembersToday nbrWallets
# Si il manque un jour sans transaction, on le génère
dateYesterday=$(awk -F '-' '{ print $3"-"$2"-"$1 }' <<<$blockDate | xargs -i date -d "{}-1day" '+%d-%m-%y')
if [[ $dateYesterday != $blockDateLast ]];then
blockDateLast=$dateYesterday
((nbrDays++))
# Obtention du dividende à ce block
lastUdBloc=$(head -n$nbrDays <<<"$udBlocs" | tail -n1)
[[ -z $lastUdBloc ]] && lastUdBloc=$(echo "$udBlocs" | tail -n1)
local blocUD=$(curl -s ${DUNITER}/blockchain/block/$lastUdBloc | jq '.membersCount,.dividend')
UDToday=$(echo "$blocUD" | tail -n1 | xargs -i echo "scale=2; {}/100" | bc)
# Calcul du nombre de nouveaux membres à ce block
nbrMembersTotalToday=$(echo "$blocUD" | head -n1)
[[ -z $nbrMembersYesterday ]] && nbrMembersYesterday=0
nbrMembersToday=$(($nbrMembersTotalToday-$nbrMembersYesterday))
jsonify
nbrMembersYesterday=$nbrMembersTotalToday
unset nbrMembersToday
fi
((nbrDays++))
fi
unset recusJson
# Sauvegarde la date de ce bloc pour l'itération suivante
blockDateLast=$blockDate
# Ajoute la valeur des transactions reçus de ce bloc au reste de la journée
for k in $walletsReceivedBloc; do
local pubkey=$(echo $k | awk -F '|' '{ print $1 }')
local value=$(echo $k | awk -F '|' '{ print $2 }')
if [[ $(echo "$membresPubkeys" | grep $pubkey) ]]; then
#valueReceivedM=$(($valueReceivedM+$value))
[[ -z $valueReceivedM ]] && valueReceivedM=0
valueReceivedM=$(echo "$valueReceivedM+$value" | bc)
pubkeyReceiveM+=${pubkey}\\n
else
#valueReceivedW=$(($valueReceivedW+$value))
[[ -z $valueReceivedW ]] && valueReceivedW=0
valueReceivedW=$(echo "$valueReceivedW+$value" | bc)
pubkeyReceiveW+=${pubkey}\\n
fi
done
# Ajoute la valeur des transactions envoyés de ce bloc au reste de la journée
for k in $walletsSentToday; do
local pubkey=$(echo $k | awk -F '|' '{ print $1 }')
local value=$(echo $k | awk -F '|' '{ print $2 }')
if [[ $(echo "$membresPubkeys" | grep $pubkey) ]]; then
#valueSentM=$(($valueSentM+$value))
[[ -z $valueSentM ]] && valueSentM=0
valueSentM=$(echo "$valueSentM+$value" | bc)
pubkeySentM+=${pubkey}\\n
else
#valueSentW=$(($valueSentW+$value))
[[ -z $valueSentW ]] && valueSentW=0
valueSentW=$(echo "$valueSentW+$value" | bc)
pubkeySentW+=${pubkey}\\n
fi
done
# Affiche la progression de la boucle si on est pas en mode web
local progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc)
local endExec=$(($(date +%s%N)/1000000))
local timeExec=$(echo "scale=3; ($endExec-$startExec)/1000" | bc)
#[[ -z $midTimeExec ]] && midTimeExec=$timeExec
[[ $incExec == 1 ]] && midTimeExecCum=0
local midTimeExecCum=$(echo "scale=3; $midTimeExecCum+$timeExec" | bc)
local midTimeExec=$(echo "scale=3; $midTimeExecCum/$incExec" | bc)
((incExec++))
if [[ $isWeb != "web" ]]; then
tput cuu1;tput el;tput cuu1;tput el;tput cuu1;tput el;tput cuu1;tput el;tput cuu1;tput el; # Clear the last view
echo -e "Heure de début: $startTime\n
\rScan en cours: $progress% - $bloc/$lastBloc (Boucle $i)
\rDate: $blockDate (Jour $nbrDays)
\rTemps d'execution: $midTimeExec"
else
[[ -z $firstScan ]] && echo "Scan des blocs avec transactions en cours ..." && local firstScan=true
fi
# [[ $i -ge $1 ]] && break #kopa
done
[[ $blockDateLast == $blockDate ]] && applyToday
# Retire la dernière virgule et ajoute le crochet de fin de JSON
sed -i '$ s/,//g' $jsonFile
echo "]" >> $jsonFile
# 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
[[ ! -d $GPATH/cache ]] && mkdir $GPATH/cache
echo -e "$lastBloc\n$wallets\n---\n$walletsAuj\n---\n$nbrMembersYesterday|$blockDateLast|$nbrDays" > $GPATH/cache/walletsUp-$i
}

View File

@ -1,12 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
cacheFile=$(ls $GPATH/cache/walletsUp-*)
cacheID=$(echo $cacheFile | awk -F '-' '{ print $NF }')
#rm -f cache/bk-walletsUp-*
cp $cacheFile $GPATH/cache/bk-walletsUp-$cacheID
cp $GPATH/db/daily.json $GPATH/db/bk-daily.json-$cacheID

View File

@ -1,19 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
source $GPATH/.env
lastDate=$(jq -r .[].date $GPATH/db/daily.json | tail -n1)
j=0
for i in $(jq -r .[].date $GPATH/db/daily.json); do
((j++))
[[ $j == $lastDate ]] && break
date=$(awk -F '-' '{ print $3"-"$2"-"$1 }' <<<"$i")
if ! [[ $(grep $(date -d "$date+1day" '+%d-%m-%y') <<<$(jq -r .[].date $GPATH/db/daily.json)) ]]; then
tput cuu1
echo -e "\nDate manquante: $(date -d "$date+1day" '+%d-%m-%y'): $j"
else
! (( $j % 3 )) && echo -en "\rScan en cours ... $i"
fi
done

View File

@ -1,27 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
source $GPATH/.env
day=$1
[[ -z $day ]] && day=$(jq .[].date $GPATH/db/daily.json | wc -l)
#bloc=$(grep -n . $GPATH/db/debug/udblocs | grep -E "^$day:" | cut -d: -f2)
bloc=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | grep -n . | grep -E "^$day:" | cut -d: -f2)
chainData=$(curl -s ${DUNITER}/blockchain/block/$bloc | jq '.membersCount,.monetaryMass')
chainMass=$(tail -n1 <<<"$chainData" | xargs -i echo "scale=2; {}/100" | bc)
chainMbr=$(head -n1 <<<"$chainData")
((day--))
Date=$(date -d "17-03-08+${day}day" '+%d-%m-%y')
jsonMass=$($GPATH/explorer.sh mass $Date -c | jq .monetaryMass)
jsonMbr=$($GPATH/explorer.sh day $Date -c | jq .nbrMembers)
#if [[ $jsonMbr != $chainMbr ]]; then
echo "$Date - $bloc - $day
json : $jsonMbr - $jsonMass
chain: $chainMbr - $chainMass
"
#fi

View File

@ -1,3 +0,0 @@
#!/bin/bash
jq -r '.[] | "---", .date, .rWallets + .rMembres' db/recus.json > db/somme.txt

View File

@ -1,12 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
source $GPATH/.env
echo "Génération du cache txblocs..."
curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]' > $GPATH/db/debug/txblocs
echo "Génération du cache membersPubkeys..."
curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey' > $GPATH/db/debug/membresPubkeys
echo "Génération du cache udblocs..."
curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' > $GPATH/db/debug/udblocs

View File

@ -1,23 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
log="/var/log/geoloc-members.log"
echo "### $(date +'%d-%m-%y - %H:%M') ###" >> $log
result=$($JAKLIS geolocProfiles)
finalResult=$(echo "$result" | jq .)
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "$finalResult" > $WEBPATH/data/geoloc-members.json
echo "OK" >> $log
else
echo "Failed" >> $log
fi
echo "---" >> $log

View File

@ -1,66 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
node=$(cut -d '/' -f3 <<<"$DUNITER")
#Check if Jaklis is installed
[[ -z $JAKLIS ]] && JAKLIS=$(which silkaj)
[[ -z $JAKLIS ]] && echo "Erreur: Vous devez installer Jaklis." && exit 1
work() {
for i in $wallets; do
exec() {
jsonResult=$($JAKLIS idBalance -p $i 2>/dev/null)
}
exec
while [[ $? == 1 ]]; do echo "Erreur $k: $i"; ((k++)); exec; done
unset k
balance=$(echo "$jsonResult" | jq -r '.balance')
[[ $balance == "null" ]] && balance="0"
username=$(echo "$jsonResult" | jq -r '.idty.username')
[[ $username == "null" ]] && username=""
formatedBalance=$(printf "%-10s | %-45s | %-1s" $balance $i $username)
if [[ $1 == "members" ]]; then
htmlBloc="$htmlBloc"$'\n'"<tr><td>$balance</td><td>$i</td><td><b>$username</b></td></tr>"
unset username
else
htmlBloc="$htmlBloc"$'\n'"<tr><td>$balance</td><td>$i</td><td>$username</td></tr>"
fi
unset balance
echo "$formatedBalance" | tee -a /tmp/balance-g1.txt
totalBalance="$totalBalance"$'\n'"$formatedBalance"
echo "$jsonResult" >> /home/poka/debugJsonForbes.log
# For tests only
# [[ $i == "13fn6X3XWVgshHTgS8beZMo9XiyScx6MB6yPsBB5ZBia" ]] && break
# [[ $i == "12JDJibbgZPRfD6Hoecg8rQRvCR5VYrMnqzfhQYmAr3k" ]] && break
done
}
wallets=$(cat $WEBPATH/data/wallets-g1-membres.txt 2>/dev/null)
[[ -z $wallets ]] && wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-membres.txt)
work members && unset wallets
wallets=$(cat $WEBPATH/data/wallets-g1-simple.txt 2>/dev/null)
[[ -z $wallets ]] && wallets=$(curl -s https://g1-stats.axiom-team.fr/data/wallets-g1-simple.txt)
work && unset wallets
totalBalance=$(sort -nr <<<$totalBalance)
[[ ! -d $GPATH/db ]] && mkdir $GPATH/db
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt && rm /tmp/balance-g1.txt
# Construct HTML
cp $GPATH/tpl/css/wallets_balance.css $WEBPATH/css/
cp $GPATH/tpl/js/wallets_balance.js $WEBPATH/js/
cp $GPATH/tpl/wallets_balance.html $WEBPATH/data/wallets_balance.html
sort -Vr <<<"$htmlBloc" > /tmp/solde_g1_html.txt
printf '%s\n' '/_LINE/r /tmp/solde_g1_html.txt' 1 '/_LINE/d' w | ed $WEBPATH/data/wallets_balance.html > /dev/null
sed -i "0,/_DATE/s//$(date '+%d-%m-%Y')/" $WEBPATH/data/wallets_balance.html
rm /tmp/solde_g1_html.txt

View File

@ -1,21 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
if [[ $1 ]]; then
cacheID=$1
cacheFile="$GPATH/cache/bk-walletsUp-$cacheID"
else
cacheFile=$(ls $GPATH/cache/bk-walletsUp-* | tail -n1)
cacheID=$(echo $cacheFile | awk -F '-' '{ print $NF }')
fi
if [[ -f $cacheFile ]]; then
rm -f $GPATH/cache/walletsUp-*
cp $cacheFile $GPATH/cache/walletsUp-$cacheID
cp $GPATH/db/bk-daily.json-$cacheID $GPATH/db/daily.json
else
echo "Aucun cache existant au bloc $cacheID"
exit 1
fi

View File

@ -1,12 +0,0 @@
#!/bin/bash
# Récupération du chemin absolut du répertoir du script actuel
GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.."
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
source $GPATH/.env
$JAKLIS listWallets > $WEBPATH/data/forbes.json
date=$(date -d '+1 minute' +"%d/%m/%Y à %H:%M")
sed -i "/<div id=\"dataDate\">/!b;n;cCes données ont été actualisées le $date" $WEBPATH/data/search.html

View File

@ -1,41 +1,12 @@
#charts {
width: 98%;
margin-left: 0px;
overflow-x: scroll;
/* display: none; */
}
.chartWrapper {
position: relative;
background-color: #DFCFBE;
border-radius: 30px;
padding: 10px;
}
.chartWrapper > canvas {
position: absolute;
left: 0;
top: 0;
pointer-events:none;
}
.chartAreaWrapper {
overflow-x: scroll;
position: relative;
width: 100%;
height: 400px;
}
.chartAreaWrapper2 {
position: relative;
height: 300px;
width: 3000px;
}
@media only screen and (max-width: 1100px) {
#charts {
width: 95%;
}
#charts {
width: 95%;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,91 +0,0 @@
body {
background-color: #c4a787 !important;
margin-top: 10px !important;
margin-left: 20px !important;
margin-right: 20px !important;
font-family: "Gill Sans", sans-serif !important;
}
.bootstrap-table .fixed-table-toolbar .bs-bars, .bootstrap-table .fixed-table-toolbar .columns, .bootstrap-table .fixed-table-toolbar .search {
float: inherit !important;
text-align: center;
display:flex;
justify-content:center;
}
.form-control {
height: calc(1.5em + .75rem + 20px) !important;
width: 500px !important;
}
.bootstrap-table .fixed-table-container .fixed-table-body {
height: inherit !important;
}
.bootstrap-table .fixed-table-container {
background-color: #DFCFBE;
border-collapse: collapse !important; /* Collapse borders */
border: 1px solid #ddd !important; /* Add a grey border */
font-size: 16px !important; /* Increase font-size */
}
.bootstrap-table .fixed-table-container th {
background-color: #B69776;
}
#dataDate {
position: absolute;
left: 50%;
transform: translate(-50%, -50%);;
bottom: 0;
}
.date {
margin-left: 2px;
}
#pseudo, #key {
background-position: 10px 12px; /* Position the search icon */
background-repeat: no-repeat; /* Do not repeat the icon image */
width: 300px; /* Full-width */
font-size: 16px; /* Increase font-size */
padding: 12px 20px 12px 20px; /* Add some padding */
border: 1px solid #ddd; /* Add a grey border */
margin-bottom: 12px; /* Add some space below the input */
margin-top: 7px;
}
#soldes {
border-collapse: collapse; /* Collapse borders */
width: 50%; /* Full-width */
border: 1px solid #ddd; /* Add a grey border */
font-size: 16px; /* Increase font-size */
background-color: #DFCFBE;
}
#soldes th, #soldes td {
text-align: left; /* Left-align text */
padding: 8px; /* Add padding */
}
#soldes tr {
/* Add a bottom border to all table rows */
border-bottom: 1px solid #ddd;
}
#soldes tr:hover {
/* Add a grey background color to the table header and on hover */
background-color: #f1f1f1;
}
#soldes th {
/* Add a grey background color to the table header and on hover */
background-color: #B69776;
cursor: pointer;
position: sticky;
top: 0px;
}
#splw {
margin-left: 20px;
}

View File

@ -1 +0,0 @@
{\n \"date\": \"_DATE\",\n \"UD\": _UDTODAY,\n \"rWallets\": _RWALLETS,\n \"sWallets\": _SWALLETS,\n \"rMembers\": _RMEMBERS,\n \"sMembers\": _SMEMBERS,\n \"nbrMembers\": _NBRMEMBERS,\n \"nbrWallets\": _NBRWALLETS\n },

View File

@ -1,63 +1,48 @@
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/charts.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/Chart.js"></script>
<script type="text/javascript" src="js/graph.js"></script>
<title>Ḡ1 Stats</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>Ḡ1 Stats</title>
</head>
<body>
<div class="header">
<center><h1>Ḡ1 Stats</h1>
| <a href="/data/daily.json">Voir le JSON g1stats</a>
| <a href="/data/search.html">Recherche</a>
| <a href="/data/wallets-g1.txt">Liste de tous les wallets</a>
| <a href="/data/wallets-g1-membres.txt">Liste des wallets membres</a>
| <a href="/data/wallets-g1-simple.txt">Liste des simples portefeuilles</a>
| <a href="/data/geoloc-members.json">Voir le JSON profiles membres</a> |
</center>
<center><h1>La Ḡ1 en quelques chiffres</h1>
<h2>Attention: ces données sont encore expérimentales, considérez les avec précaution.</h2>
<h3>Vous trouverez des statistiques plus détaillées via <a href="https://demo.cesium.app/#/app/blockchain/stats">l'explorateur Cesium</a></h3>
<a href="/graph/mixed.html">Voir les graphiques</a></center>
</div>
<div id="mainbloc">
<pre>
Date: <b>_day - _heure</b>
Noeud scanné: <b>https://g1v1.p2p.legal</b>
Date: <b>_day - _heure</b>
Noeud scanné: <b>https://duniter-g1.p2p.legal</b>
---
Nombre total de portefeuille: <b>_nbrTotalWallets</b>
Nombre total de wallet: <b>_nbrTotalWallets</b> <a href="/graph/nbr_wallets.html">Voir le graphique</a>
Nombre de membres: <b>_nbrMembers</b> (_pourcentMbrs%)
Nombre de simple portefeuille: <b>_nbrSimpleWallets</b> (_pourcentWallets%)
Nombre de simple portefeuille: <b>_nbrSimpleWallets</b> (_pourcentWallets%)
---
Reçus simples portefeuille: <b>_sumRW Ḡ1</b>
Envoyé simples portefeuille: <b>_sumSW Ḡ1</b>
Soldes simples portefeuille: <b>_soldeW Ḡ1</b> (_pourcentSimpleWallet% de la masse monétaire totale)
Reçus simples portefeuille: <b>_txInSimple Ḡ1</b> <a href="/graph/recus.html">Voir le graphique</a>
Envoyé simples portefeuille: <b>_txOutSimple Ḡ1</b>
Soldes simples portefeuille: <b>_soldeSimple Ḡ1</b> (_pourcentSimpleWallet% de la masse monétaire totale)
---
Reçus membres: <b>_sumRM Ḡ1</b> (sans les DU)
Envoyé membres: <b>_sumSM Ḡ1</b>
Soldes membres: <b>_soldeM Ḡ1</b> (sans les DU)
Reçus membres: <b>_txInMembers Ḡ1</b> (sans les DU) <a href="/graph/recus.html">Voir le graphique</a>
Envoyé membres: <b>_txOutMembers Ḡ1</b>
Soldes membres: <b>_soldeMembers Ḡ1</b> (sans les DU)
---
Masse monétaire: <b>_monetaryMass Ḡ1</b>
Masse monétaire: <b>_monetaryMass Ḡ1</b>
---
<h3>Analyse rapide</h3>
<b>_sleepyG1%</b> des Ḡ1 n'ont jamais été utilisés.
</pre>
</div>
<div id="charts">
<center><h2 id="titleRW">Ḡ1 reçus sur les portefeuilles</h2></center>
<canvas id="chartRW" width="1600" height="500"></canvas>
</div>
</center>
<div id="charts">
<center><h2 id="titleNBRW">Nombre de portefeuilles</h2></center>
<canvas id="chartNBRW" width="1600" height="500"></canvas>
</div>
</center>
<center>
| <a href="/wallets-g1.txt">Liste de tous les wallets</a>
| <a href="/wallets-g1-membres.txt">Liste des wallets membres</a>
| <a href="/wallets-g1-simple.txt">Liste des simples portefeuilles</a> |
<br><br>
Ces données sont mises à jours toutes les 3 heures.<br>

View File

@ -1,139 +0,0 @@
var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) {
var date = jsonfileRW.responseJSON.map(function(e) {
return e.date;
});
var rwallets = jsonfileRW.responseJSON.map(function(e) {
return e.rWallets;
});
var rmembers = jsonfileRW.responseJSON.map(function(e) {
return e.rMembers;
});
var nbrwallets = jsonfileRW.responseJSON.map(function(e) {
return e.nbrWallets;
});
var nbrmembers = jsonfileRW.responseJSON.map(function(e) {
return e.nbrMembers;
});
//var optionsGen = 'pointBorderWidth: 1, pointHoverRadius: 6, pointHoverBackgroundColor: "beige", pointHoverBorderColor: "brown", pointHoverBorderWidth: 2, pointRadius: 1, pointHitRadius: 4';
//Received Graph
var ctx = document.getElementById("chartRW");
var config = {
type: 'line',
data: {
labels: date,
datasets: [
{
label: 'Portefeuilles membres',
data: rmembers,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
},
{
label: 'Simples portefeuilles',
data: rwallets,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
},
]
},
options: {
maintainAspectRatio: false,
responsive: true,
scales: {
xAxes: [{
stacked: true
}],
yAxes: [
{
id: 'y-axis',
stacked: true
}
]
}
}
};
var myChartRW = new Chart(ctx, config);
// NbrWallets Graph
var ctx = document.getElementById("chartNBRW");
var config = {
type: 'line',
data: {
labels: date,
datasets: [
{
label: 'Portefeuilles membres',
data: nbrmembers,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
},
{
label: 'Simples portefeuilles',
data: nbrwallets,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 6,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 4
}]
},
options: {
maintainAspectRatio: true,
responsive: true,
scales: {
xAxes: [{
stacked: true
}],
yAxes: [
{
id: 'y-axis',
stacked: true
}
]
}
}
};
var myChartNBRW = new Chart(ctx, config);
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,72 +0,0 @@
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
// Sort work
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
const table = th.closest('table');
Array.from(table.querySelectorAll('tr:nth-child(n+2)'))
.sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
.forEach(tr => table.appendChild(tr) );
})));
// Search
function recherche(select) {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById(select);
filter = input.value.toUpperCase();
table = document.getElementById("soldes");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
if (select == "pseudo") { td = tr[i].getElementsByTagName("td")[2]; }
else if (select == "key") { td = tr[i].getElementsByTagName("td")[1]; }
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
// Affichage des simples portefeuilles
var checkWallets = document.querySelector('input[value="splw"]');
checkWallets.onchange = function() {
var table, tr, td, i, txtValue;
table = document.getElementById("soldes");
tr = table.getElementsByTagName("tr");
if(checkWallets.checked) {
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[2];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue == " ") {
tr[i].style.display = "";
}
}
}
} else {
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[2];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue == " ") {
tr[i].style.display = "none";
}
}
}
}
};

View File

@ -4,14 +4,8 @@
<meta charset="utf-8">
<title>Ḡ1 Stats - Graphiques</title>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="../css/charts.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script type="text/javascript" src="../js/Chart.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="https://hammerjs.github.io/dist/hammer.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom@0.7.7"></script>
<script type="text/javascript" src="graph.js"></script>
<link rel="stylesheet" type="text/css" href="../css/charts.css">
<script type="text/javascript" src="../js/Chart.js"></script>
</head>
<body>
@ -28,6 +22,121 @@
</div>
</center>
<script>
// ### For received on wallets ###
var jsonfileRW = {
"jsonarray": [
_JSONDATARW
]
};
var date = jsonfileRW.jsonarray.map(function(e) {
return e.date;
});
var rwallets = jsonfileRW.jsonarray.map(function(e) {
return e.rWallets;
});
var rmembres = jsonfileRW.jsonarray.map(function(e) {
return e.rMembres;
});
var ctx = document.getElementById("chartRW");
var config = {
type: 'line',
data: {
labels: date,
datasets: [{
label: 'Ḡ1 reçus sur les simples portefeuilles',
data: rwallets,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 8,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 3,
pointHitRadius: 8
}, {
label: 'Ḡ1 reçus sur les portefeuilles membres',
data: rmembres,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 8,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 3,
pointHitRadius: 8
}]
},
options: {
// maintainAspectRatio: false,
// responsive: false
}
};
var myChartRW = new Chart(ctx, config);
// ### For numbers of wallets ###
var jsonfileNBRW = {
"jsonarray": [
_JSONDATANBRW
]
};
var date = jsonfileNBRW.jsonarray.map(function(e) {
return e.date;
});
var nbrwallets = jsonfileNBRW.jsonarray.map(function(e) {
return e.nbrWallets;
});
var nbrmembres = jsonfileNBRW.jsonarray.map(function(e) {
return e.nbrMembres;
});
var ctx = document.getElementById("chartNBRW");
var config = {
type: 'line',
data: {
labels: date,
datasets: [{
label: 'Nombre de simple portefeuilles',
data: nbrwallets,
backgroundColor: 'rgba(0, 119, 204, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 8,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 3,
pointHitRadius: 8
}, {
label: 'Nombre de portefeuilles membres',
data: nbrmembres,
backgroundColor: 'rgba(0, 178, 0, 0.3)',
pointBorderWidth: 1,
pointHoverRadius: 8,
pointHoverBackgroundColor: "beige",
pointHoverBorderColor: "brown",
pointHoverBorderWidth: 2,
pointRadius: 3,
pointHitRadius: 8
}]
},
options: {
// maintainAspectRatio: false,
// responsive: false
}
};
var myChartNBRW = new Chart(ctx, config);
</script>
<div class="blank"></div>
<div class="footer">
<center><p>Les données démarrent le 15-11-19, jour de lancement du service g1-stats.<br>

1
tpl/recus.json Normal file
View File

@ -0,0 +1 @@
{\n \"date\": \"_DATE\",\n \"rWallets\": \"_RWALLETS\",\n \"rMembres\": \"_RMEMBRES\"\n },

View File

@ -1,39 +0,0 @@
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/wallets_balance.css">
<link rel="stylesheet" href="../css/src/bootstrap.min.css">
<link rel="stylesheet" href="../css/src/bootstrap-table.min.css">
<script src="../js/src/jquery.min.js"></script>
<script src="../js/src/popper.min.js"></script>
<script src="../js/src/bootstrap.min.js"></script>
<script src="../js/src/bootstrap-table.min.js"></script>
<script src="../js/src/bootstrap-table-fr-FR.min.js"></script>
</head>
<body>
<table id="walletsTable" data-toggle="table" data-locale="fr-FR" data-pagination="true" data-page-size='10' data-page-list="[10, 25, 50, 100, 500, all]" data-search="true" data-url="forbes.json">
<thead>
<tr>
<th data-sortable="true" data-field="pubkey">Clé publique</th>
<th data-sortable="true" data-field="id.username">Pseudo</th>
<th data-sortable="true" data-field="id.isMember">Membre</th>
<th data-sortable="true" data-field="balance">Solde (Ğ1)</th>
</tr>
</thead>
</table>
<br><br>
<center>
<div id="dataDate">
Ces données ont été actualisées le 18/10/2021 à 06:16
</div>
</center>
</body>
</html>

View File

@ -1,20 +0,0 @@
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/wallets_balance.css">
</head>
<body>
<div class="date"> Données générées le _DATE<br></div>
<input type="text" id="pseudo" onkeyup="recherche('pseudo')" placeholder="Rechercher un pseudo...">
<input type="text" id="key" onkeyup="recherche('key')" placeholder="Rechercher une clé publique...">
<input type="checkbox" id="splw" value="splw" checked><label for="splw">Afficher les simples portefeuilles</label>
<table id="soldes">
<tr><th>Solde (Ḡ1)</th><th>Clé publique</th><th>Identifiant utilisateur</th></tr>
_LINE
</table>
<script type="text/javascript" src="../js/wallets_balance.js"></script>
</body>
</html>

58
transform_json.sh Executable file
View File

@ -0,0 +1,58 @@
#!/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