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
scripts/.loc_hash
.idea
/public/uploads
/tmp
vendor
composer.json
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')
echo "### $date ###"
## Inistialisation
## Initialisation
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=$(echo "$TXBLOCKS" | tail -n 2 | tr '\n' ' ')
keyword="\[Achat GMarche] : "
[ ! -e .loc_hash ] && touch .loc_hash
## Récupération des transactions avec commentaire GMarche
for i in $TXBLOCKS; do
result=$(curl -s $DUNITER/blockchain/block/$i | jq '.transactions[].comment' | grep -v '""' | tr -d '"')
result=$(echo "$result" | grep "$keyword")
[[ ! -z $result ]] && isSell+=$(echo -e "$result;")
result=$(curl -s $DUNITER/blockchain/block/$i | jq '.transactions[].hash, .transactions[].comment' | grep -v '""' | tr -d '"' | grep -B1 "$keyword")
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
sleep 1
done
@ -26,8 +32,13 @@ req="SELECT pubkey FROM users;"
usersPubkeys=$(sudo mysql --database gmarche -e "$req" | grep .)
for i in $usersPubkeys; do
isSell+=$(curl -s $DUNITER/tx/history/$i/pending | jq '. | select(.history.sending == [])' | jq '.history.pending[].comment' | tr -d '"')
#[ ! -z "$pendingTX" ] && echo "$pendingTX"
result=$(curl -s $DUNITER/tx/history/$i/pending | jq '. | select(.history.sending == [])' | jq '.history.pending[].hash,.history.pending[].comment' | tr -d '"')
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
## Retrait de l'identifiant gmarche des commentaires