first
This commit is contained in:
commit
d98fd99695
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
|
||||
### Variable ###
|
||||
DUNITER="https://duniter-g1.p2p.legal"
|
||||
###
|
||||
|
||||
echo "Initialisation ..."
|
||||
id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
outFile="/tmp/g1-stats_$id"
|
||||
TXBLOCKS=($(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]' | awk '{printf $1" "}'))
|
||||
MEMBERS=($(curl -s ${DUNITER}/wot/members | jq '.results[].pubkey' | tr -d '"'))
|
||||
nbrMembers=${#MEMBERS[@]}
|
||||
lastBloc=${TXBLOCKS[-1]}
|
||||
|
||||
startTime=$(date +'%T')
|
||||
|
||||
for i in ${TXBLOCKS[*]}; do
|
||||
|
||||
[[ -z ${TXBLOCKS[$i]} ]] && break
|
||||
WALLETS=$(curl -s ${DUNITER}/blockchain/block/${TXBLOCKS[$i]} | jq '.transactions[].outputs[]' | tr -d '"' | awk -F '(' '{ print $2 }' | tr -d ')')
|
||||
bloc=${TXBLOCKS[$i]}
|
||||
wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g')
|
||||
|
||||
progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc)
|
||||
|
||||
clear
|
||||
echo "Heure de début: $startTime"
|
||||
echo
|
||||
echo "Scan en cours: $progress% - $bloc/$lastBloc"
|
||||
|
||||
((iter++))
|
||||
|
||||
done
|
||||
|
||||
echo -e "$(echo -e "$wallets" | sort -u)" > $outFile
|
||||
|
||||
iter=0
|
||||
for i in ${MEMBERS[*]}; do
|
||||
|
||||
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
|
||||
clear
|
||||
echo "Heure de début: $startTime"
|
||||
echo
|
||||
echo "Scan en cours: 100% - $bloc/$lastBloc"
|
||||
echo "Ajouts des comptes membres ... $progress%"
|
||||
fi
|
||||
|
||||
if [[ -z $(grep "$i" $outFile) ]]; then
|
||||
echo -e "$i" >> $outFile
|
||||
fi
|
||||
|
||||
((iter++))
|
||||
done
|
||||
|
||||
nbrTotalWallets=$(cat $outFile | 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)
|
||||
|
||||
echo -e "\n ---"
|
||||
echo "Nombre total de wallet: $nbrTotalWallets"
|
||||
echo "Nombre de membres: $nbrMembers (${pourcentMbrs}%)"
|
||||
echo "Nombre de simple portefeuille: $nbrSimpleWallets (${pourcentWallets}%)"
|
||||
echo "---"
|
||||
|
||||
rm $outFile
|
||||
echo "Heure de fin: $(date +'%T')"
|
Loading…
Reference in New Issue