This commit is contained in:
poka 2020-09-21 04:57:13 +02:00
parent 56525b7785
commit b67de6d2d1
2 changed files with 8 additions and 6 deletions

View File

@ -7,9 +7,10 @@
# Git: https://git.p2p.legal/axiom-team/g1-stats
################################################################################
# Stop if error
# Exit script if error
set -e
# Récupération du chemin absolut du répertoir du script actuel
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
@ -19,17 +20,20 @@ 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 bc) ]] && apt update && apt install jq bc
[[ -z $(which jq) || -z $(which bc) || -z $(which curl) ]] && sudo apt update && sudo apt install jq bc curl
echo "Initialisation ..."
#TXBLOCKS=$(cat $SCRIPTPATH/db/txblocs) #kopa
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]'
echo "TXBLOCKS OK"
membresPubkeys=$(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')
#membresPubkeys=$(cat db/membresPubkeys) #kopa
echo "membresPubkeys OK"
nbrMembers=$(echo "$membresPubkeys" | wc -l)
lastBloc=${TXBLOCKS[-1]}
udBlocs=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]')
echo "udBlocs OK"
isWeb=$1
jsonFile="$SCRIPTPATH/db/daily.json"
@ -38,7 +42,7 @@ source $SCRIPTPATH/lib/functions.sh
source $SCRIPTPATH/lib/scanTxWallets.sh
### Extraction des adresses Ḡ1 actives
scanTxWallets $1 #kopa
scanTxWallets #kopa
### Calcul la somme des soldes portefeuilles et membres
sumSoldes
@ -53,7 +57,6 @@ nbrWallets
displayStats
### Renseignement de l'index web et indexation de l'historique
# source $SCRIPTPATH/lib/functions.sh # On source les fonctions de nouveau
[[ $isWeb == "web" ]] && web
### Fin de programme

View File

@ -191,7 +191,7 @@ scanTxWallets() {
echo "Scan des blocs avec transactions en cours ..."
fi
# [[ $i -ge $1 ]] && break #kopa
# [[ $i -ge 10 ]] && break #kopa
done
[[ $blockDateLast == $blockDate ]] && applyToday
@ -206,4 +206,3 @@ scanTxWallets() {
[[ ! -d $SCRIPTPATH/cache ]] && mkdir $SCRIPTPATH/cache
echo -e "$lastBloc\n$wallets\n---\n$walletsAuj\n---\n$nbrMembersYesterday|$blockDateLast" > $SCRIPTPATH/cache/walletsUp-$i
}