Browse Source

Cache every day; Catch 1006 ucode

master
poka 8 months ago
parent
commit
19b7cb156f
  1. 3
      g1-stats.sh
  2. 18
      lib/functions.sh
  3. 31
      lib/scanTxWallets.sh

3
g1-stats.sh

@ -29,7 +29,8 @@ if $debug; then
udBlocs=$(cat $GPATH/db/debug/udblocs)
echo # To clean next progress view
else
TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
# TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS=$(cat $GPATH/tx.json | jq '.result.blocks[]')
echo "TXBLOCKS OK"
membresPubkeys=$(curl -s ${DUNITER}/wot/members | jq -r '.results[].pubkey')
tput cuu1;tput el;

18
lib/functions.sh

@ -132,3 +132,21 @@ Analyse
---
$sleepyG1% des Ḡ1 n'ont jamais été utilisés."
}
rmOldCache() {
keepCache=20
listCache=$(ls -l $GPATH/db/bk-* | awk '{ print $9 }')
listID=$(echo "$listCache" | awk -F '-' '{ print $NF }')
nbrID=$(echo "$listID" | wc -l)
nbrToSup=$((nbrID-$keepCache))
if [[ $nbrToSup -ge 0 ]]; then
cacheIDToSup=$(echo "$listID" | head -n$nbrToSup)
for i in $cacheIDToSup; do
rm $GPATH/db/bk-daily.json-$i
rm $GPATH/cache/bk-walletsUp-$i
done
fi
}

31
lib/scanTxWallets.sh

@ -13,8 +13,8 @@ scanTxWallets() {
local nbrMembersYesterday=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 1)
local blockDateLast=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 2)
local nbrDays=$(cat "$startFile" | sed -e '1,/---/d' | sed -e '1,/---/d' | sed '/---/Q' | grep . | cut -d '|' -f 3)
#! ($debug) &&
[[ $lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]} ]] && return
#! ($debug) &&
[[ $lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]} ]] && echo "$lastBloc -le $startBloc || $startIter -ge ${#TXBLOCKS[@]}" && return
rm $startFile
else
local startIter=0
@ -24,6 +24,7 @@ scanTxWallets() {
fi
incExec=1
for ((i=$startIter; i<${#TXBLOCKS[@]}; i++)); do
local nbrIteration=$i
local startExec=$(($(date +%s%N)/1000000))
local bloc=${TXBLOCKS[$i]}
[[ -z $bloc ]] && break
@ -31,6 +32,11 @@ scanTxWallets() {
# Récupération du bloc courant
local blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
while [[ $(jq -r '.ucode' <<<"$blocFull") == 1006 ]]; do
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull"
sleep 2
blocFull=$(curl -s ${DUNITER}/blockchain/block/$bloc)
done
until blocBrut=$(jq -r '.' <<<"$blocFull" 2>/dev/null); do
[[ $isWeb != "web" ]] && echo -e "i: $i\n$blocFull"
sleep 2
@ -38,6 +44,10 @@ scanTxWallets() {
done
[[ -z "$blocBrut" ]] && continue
echo "$blocFull" > debugTmp.txt
echo "-----------------------------------" >> debugTmp.txt
echo "$blocBrut" >> debugTmp.txt
# Récupération de la date du block
local blockDate=$(jq '.medianTime' <<<"$blocBrut")
#kopa echo "$blocBrut"
@ -141,6 +151,23 @@ scanTxWallets() {
nbrMembersToday=$(($nbrMembersTotalToday-$nbrMembersYesterday))
jsonify
# Mise en cache périodique
## On supprime les doublons et les lignes vides
wallets=$(echo -e "$wallets" | sort -u | awk 'NF')
# if ((i % 50 == 0)); then #kopaa
echo -e "$bloc\n$wallets\n---\n$walletsAuj\n---\n$nbrMembersYesterday|$blockDateLast|$nbrDays" > $GPATH/cache/bk-walletsUp-$nbrIteration
cp $GPATH/db/daily.json $GPATH/db/bk-daily.json-$nbrIteration
## Retire la dernière virgule et ajoute le crochet de fin de JSON
sed -i '$ s/,//g' $GPATH/db/bk-daily.json-$nbrIteration
echo "]" >> $GPATH/db/bk-daily.json-$nbrIteration
## On supprime le vieux cache
rmOldCache
# fi
}
if [[ -n $blockDateLast && $blockDateLast != $blockDate ]]; then

Loading…
Cancel
Save