Lock transaction hash ever applied

This commit is contained in:
poka 2019-11-24 04:44:56 +01:00
parent 1987ca71b3
commit 022cf49eea
2 changed files with 19 additions and 7 deletions

3
.gitignore vendored
View File

@ -1,8 +1,9 @@
config/config.php config/config.php
scripts/.loc_hash
.idea .idea
/public/uploads /public/uploads
/tmp /tmp
vendor vendor
composer.json composer.json
composer.lock composer.lock
/src/Framework/SwiftMailerFactory.php /src/Framework/SwiftMailerFactory.php

View File

@ -6,17 +6,23 @@ start=`date +%s`
date=$(date +'%d-%m-%y à %H:%M') date=$(date +'%d-%m-%y à %H:%M')
echo "### $date ###" echo "### $date ###"
## Inistialisation ## Initialisation
DUNITER=$(grep g1_node ../config/config.php | awk '{ print $3}' | tr -d ';' | tr -d "'") DUNITER=$(grep g1_node ../config/config.php | awk '{ print $3}' | tr -d ';' | tr -d "'")
TXBLOCKS=$(curl -s $DUNITER/blockchain/with/tx | jq '.result.blocks[]') TXBLOCKS=$(curl -s $DUNITER/blockchain/with/tx | jq '.result.blocks[]')
TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 2 | tr '\n' ' ') TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 2 | tr '\n' ' ')
keyword="\[Achat GMarche] : " keyword="\[Achat GMarche] : "
[ ! -e .loc_hash ] && touch .loc_hash
## Récupération des transactions avec commentaire GMarche ## Récupération des transactions avec commentaire GMarche
for i in $TXBLOCKS; do for i in $TXBLOCKS; do
result=$(curl -s $DUNITER/blockchain/block/$i | jq '.transactions[].comment' | grep -v '""' | tr -d '"') result=$(curl -s $DUNITER/blockchain/block/$i | jq '.transactions[].hash, .transactions[].comment' | grep -v '""' | tr -d '"' | grep -B1 "$keyword")
result=$(echo "$result" | grep "$keyword") rhash=$(echo "$result" | head -n1)
[[ ! -z $result ]] && isSell+=$(echo -e "$result;") rcom=$(echo "$result" | tail -n1)
if [[ ! -z $result && -z $(grep $rhash .loc_hash) ]]; then
isSell+=$(echo -e "$rcom;")
echo "$rhash" >> .loc_hash
fi
sleep 1 sleep 1
done done
@ -26,8 +32,13 @@ req="SELECT pubkey FROM users;"
usersPubkeys=$(sudo mysql --database gmarche -e "$req" | grep .) usersPubkeys=$(sudo mysql --database gmarche -e "$req" | grep .)
for i in $usersPubkeys; do for i in $usersPubkeys; do
isSell+=$(curl -s $DUNITER/tx/history/$i/pending | jq '. | select(.history.sending == [])' | jq '.history.pending[].comment' | tr -d '"') result=$(curl -s $DUNITER/tx/history/$i/pending | jq '. | select(.history.sending == [])' | jq '.history.pending[].hash,.history.pending[].comment' | tr -d '"')
#[ ! -z "$pendingTX" ] && echo "$pendingTX" rhash=$(echo "$result" | head -n1)
rcom=$(echo "$result" | tail -n1)
if [[ ! -z $result && -z $(grep $rhash .loc_hash) ]]; then
isSell+=$(echo -e "$rcom;")
echo "$rhash" >> .loc_hash
fi
done done
## Retrait de l'identifiant gmarche des commentaires ## Retrait de l'identifiant gmarche des commentaires