Extraction de quelques chiffres liés à la ḡ1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

73 lines
2.1 KiB

#!/bin/bash
################################################################################
# Author: Poka (poka@p2p.legal)
# Version: 0.3.0
# 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
### Initialisation des données ###
startTime=$(date +'%H:%M')
day=$(date +'%y-%m-%d')
dayP=$(date +'%d-%m-%y')
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
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[]')
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=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
nbrMembers=$(echo "$membresPubkeys" | wc -l)
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
scanTxWallets
### Calcul la somme des soldes portefeuilles et membres
sumSoldes
### Ajout des membres sans transaction
addMembers
### Calcul du nombre de wallets
nbrWallets
### Affichage des stats
displayStats
### Renseignement de l'index web et indexation de l'historique
[[ $isWeb == "web" ]] && web
### Fin de programme
day=$(date +'%d-%m-%y')
echo "
---
$day - Heure de fin: $(date +'%H:%M')"