From 022cf49eea1b2c84bc27585255b02d4f281ab745 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 24 Nov 2019 04:44:56 +0100 Subject: [PATCH] Lock transaction hash ever applied --- .gitignore | 3 ++- scripts/check_sold.sh | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 4df4448..c18e309 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ config/config.php +scripts/.loc_hash .idea /public/uploads /tmp vendor composer.json composer.lock -/src/Framework/SwiftMailerFactory.php \ No newline at end of file +/src/Framework/SwiftMailerFactory.php diff --git a/scripts/check_sold.sh b/scripts/check_sold.sh index d856203..1aaba9e 100755 --- a/scripts/check_sold.sh +++ b/scripts/check_sold.sh @@ -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