2019-10-29 04:55:50 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-01 02:36:19 +02:00
|
|
|
################################################################################
|
|
|
|
# Author: Poka (poka@p2p.legal)
|
2020-09-27 22:49:14 +02:00
|
|
|
# Version: 0.3.0
|
2020-06-01 02:36:19 +02:00
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
# Git: https://git.p2p.legal/axiom-team/g1-stats
|
|
|
|
################################################################################
|
|
|
|
|
2020-09-22 02:36:20 +02:00
|
|
|
[[ -z $debug ]] && debug=false
|
2020-09-21 04:57:13 +02:00
|
|
|
# Exit script if error
|
2020-09-20 22:32:15 +02:00
|
|
|
set -e
|
|
|
|
|
2020-09-21 04:57:13 +02:00
|
|
|
# Récupération du chemin absolut du répertoir du script actuel
|
2020-09-24 21:54:55 +02:00
|
|
|
GPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
2020-09-25 02:40:08 +02:00
|
|
|
[[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env
|
|
|
|
source $GPATH/.env
|
2019-10-29 04:55:50 +01:00
|
|
|
|
2019-11-19 16:03:22 +01:00
|
|
|
### Initialisation des données ###
|
|
|
|
startTime=$(date +'%H:%M')
|
2019-12-17 00:44:01 +01:00
|
|
|
day=$(date +'%y-%m-%d')
|
2019-12-17 01:38:21 +01:00
|
|
|
dayP=$(date +'%d-%m-%y')
|
2019-11-19 16:03:22 +01:00
|
|
|
echo -e "\n############# $day à $startTime #############\n"
|
2020-09-21 04:57:13 +02:00
|
|
|
[[ -z $(which jq) || -z $(which bc) || -z $(which curl) ]] && sudo apt update && sudo apt install jq bc curl
|
2019-10-29 04:55:50 +01:00
|
|
|
echo "Initialisation ..."
|
2020-09-22 02:36:20 +02:00
|
|
|
if $debug; then
|
2020-09-24 21:54:55 +02:00
|
|
|
TXBLOCKS=$(cat $GPATH/db/debug/txblocs)
|
|
|
|
membresPubkeys=$(cat $GPATH/db/debug/membresPubkeys)
|
|
|
|
udBlocs=$(cat $GPATH/db/debug/udblocs)
|
2020-09-24 02:25:27 +02:00
|
|
|
echo # To clean next progress view
|
2020-09-22 02:36:20 +02:00
|
|
|
else
|
|
|
|
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
|
2020-09-24 01:04:11 +02:00
|
|
|
echo "TXBLOCKS OK"
|
2020-09-22 02:36:20 +02:00
|
|
|
membresPubkeys=$(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')
|
2020-09-24 02:25:27 +02:00
|
|
|
tput cuu1;tput el;
|
2020-09-24 01:04:11 +02:00
|
|
|
echo "membresPubkeys OK"
|
2020-09-22 02:36:20 +02:00
|
|
|
udBlocs=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]')
|
2020-09-24 02:25:27 +02:00
|
|
|
tput cuu1;tput el;
|
2020-09-24 01:04:11 +02:00
|
|
|
echo "udBlocs OK"
|
2020-09-22 02:36:20 +02:00
|
|
|
fi
|
|
|
|
|
2020-09-21 02:11:23 +02:00
|
|
|
TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
|
2020-09-19 01:58:18 +02:00
|
|
|
nbrMembers=$(echo "$membresPubkeys" | wc -l)
|
2019-10-29 04:55:50 +01:00
|
|
|
lastBloc=${TXBLOCKS[-1]}
|
2019-11-15 23:33:11 +01:00
|
|
|
isWeb=$1
|
2020-09-24 21:54:55 +02:00
|
|
|
jsonFile="$GPATH/db/daily.json"
|
2019-10-29 04:55:50 +01:00
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### On source les fonctions
|
2020-09-24 21:54:55 +02:00
|
|
|
source $GPATH/lib/functions.sh
|
|
|
|
source $GPATH/lib/scanTxWallets.sh
|
2020-09-15 16:50:15 +02:00
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### Extraction des adresses Ḡ1 actives
|
2020-09-21 06:39:45 +02:00
|
|
|
scanTxWallets
|
2020-06-24 21:18:23 +02:00
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### Calcul la somme des soldes portefeuilles et membres
|
|
|
|
sumSoldes
|
2020-09-15 04:05:07 +02:00
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### Ajout des membres sans transaction
|
|
|
|
addMembers
|
2020-06-24 21:18:23 +02:00
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### Calcul du nombre de wallets
|
|
|
|
nbrWallets
|
2019-11-19 16:03:22 +01:00
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### Affichage des stats
|
|
|
|
displayStats
|
2019-10-29 04:55:50 +01:00
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### Renseignement de l'index web et indexation de l'historique
|
2020-09-18 15:47:09 +02:00
|
|
|
[[ $isWeb == "web" ]] && web
|
|
|
|
|
2020-09-19 01:58:18 +02:00
|
|
|
### Fin de programme
|
2019-11-15 23:33:11 +01:00
|
|
|
day=$(date +'%d-%m-%y')
|
2020-09-22 02:36:20 +02:00
|
|
|
echo "
|
|
|
|
---
|
|
|
|
$day - Heure de fin: $(date +'%H:%M')"
|