This commit is contained in:
poka 2020-06-24 21:18:23 +02:00
parent c5e95e43b2
commit 95a053016d
2 changed files with 40 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.env
renameHistory.sh
tmp*

View File

@ -2,7 +2,7 @@
################################################################################
# Author: Poka (poka@p2p.legal)
# Version: 0.1.1
# Version: 0.2.0
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
# Git: https://git.p2p.legal/axiom-team/g1-stats
################################################################################
@ -21,8 +21,8 @@ echo -e "\n############# $day à $startTime #############\n"
echo "Initialisation ..."
outFile="/tmp/g1-stats-$day-$startTime_$id"
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS+=$(curl -s ${DUNITER2}/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS+=$(curl -s ${DUNITER3}/blockchain/with/tx | jq '.result.blocks[]')
#TXBLOCKS+=$(curl -s ${DUNITER2}/blockchain/with/tx | jq '.result.blocks[]')
#TXBLOCKS+=$(curl -s ${DUNITER3}/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS=($(echo "$TXBLOCKS" | sort -hu | awk '{printf $1" "}'))
unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]'
MEMBERS=($(curl -s ${DUNITER}/wot/members | jq '.results[].pubkey' | tr -d '"'))
@ -37,13 +37,21 @@ loopWalletUp() {
[[ -z ${TXBLOCKS[$i]} ]] && break
sleep 0.1
WALLETS0=$(curl -s ${DUNITER}/blockchain/block/${TXBLOCKS[$i]})
until WALLETS=$(echo $WALLETS0 | jq '.transactions[].outputs[]' 2>/dev/null); do
until WALLETS=$(echo $WALLETS0 | jq '.time,.transactions[].outputs[]' 2>/dev/null); do
[[ $isWeb != "web" ]] && echo -e "iter $iter \n$WALLETS0"
sleep 2
WALLETS0=$(curl -s ${DUNITER}/blockchain/block/${TXBLOCKS[$i]})
done
[[ -z "$WALLETS" ]] && echo "Erreur: $RET" && exit 1
WALLETS=$(echo "$WALLETS" | tr -d '"' | awk -F '(' '{ print $2 }' | tr -d ')')
[[ -z "$WALLETS" ]] && echo "Erreur: $RET" && exit 1
# Récupération de la date du block
blockDate=$(echo "$WALLETS" | head -n1)
blockDate=$(date -d"@$blockDate" +%y-%m-%d)
WALLETS=$(echo "$WALLETS" | tail -n +2 | tr -d '"' | awk -F '(' '{ print $2 }' | tr -d ')')
# Journalisation
echo -e "$WALLETS \n" | sed 's/ /\n/g' | sed '/^[[:space:]]*$/d' | sort -u >> $SCRIPTPATH/tmp/$blockDate
bloc=${TXBLOCKS[$i]}
wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g')
@ -56,13 +64,34 @@ loopWalletUp() {
echo "Heure de début: $startTime"
echo
echo "Scan en cours: $progress% - $bloc/$lastBloc"
echo "Date: $blockDate"
fi
((iter++))
done
}
loopWalletUp
#loopWalletUp
### Isolation des membres et wallets dans les fichiers de journalisation
lsDays=$(ls $SCRIPTPATH/tmp)
for i in $lsDays; do
walletDay=$(cat $SCRIPTPATH/tmp/$i | sort -u | tee $SCRIPTPATH/tmp/$i)
for j in $walletDay; do
if [[ $(printf '%s\n' ${MEMBERS[*]} | grep $j) ]]; then
echo $j >> $SCRIPTPATH/tmp/${i}_mbr
sed -i "/$j/d" $SCRIPTPATH/tmp/$i
fi
done
mv $SCRIPTPATH/tmp/$i $SCRIPTPATH/tmp/${i}_wallets
done
### TODO
# dateLDay=$(date -d "19-05-24" +%s)
# dateLDay=$(($dateLDay-60*60*24))
# curl -s ${DUNITER}/tx/history/TENGx7WtzFsTXwnbrPEvb6odX2WnqYcnnrjiiLvp1mS/times/1558562400/1558648800
### Ecriture des adresses actives dans un fichier tampon ###
echo -e "$(echo -e "$wallets" | sort -u)" > $outFile
@ -167,7 +196,7 @@ echo -e "\n ---\n"
simpleWallets=$(cat $outFile)
echo "Isolation des simples portefeuilles..."
for i in ${MEMBERS[@]}; do
simpleWallets=$(echo "$simpleWallets" | grep -v "$i")
simpleWallets=$(echo "$simpleWallets" | grep -v "$i")
done
### Boucle d'obtention des soldes ###
@ -178,11 +207,11 @@ 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
until txInL=$(curl -s "$ESNODE/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=recipient:$i&pretty"); do
echo "Erreur: $i"
sleep 2
done
until txOutL=$(curl -s "$ESNODE/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty"); do
until txOutL=$(curl -s "$ESNODE/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty"); do
echo "Erreur: $i"
sleep 2
done