From 9d9f8ff1485b63caec368e745639f7af1bb5b151 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 14 Feb 2022 06:52:31 +0000 Subject: [PATCH] Add extra debugging in transactions --- handler/transactions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/handler/transactions.py b/handler/transactions.py index 14ad2f7..461c3e5 100644 --- a/handler/transactions.py +++ b/handler/transactions.py @@ -40,29 +40,36 @@ class Transactions(object): if "type" not in inside: stored_trade = r.hgetall(f"tx.{txid}") - print("stored trade", stored_trade) if not stored_trade: self.log.error("Could not find entry in DB for typeless transaction: {id}", id=txid) return stored_trade = convert(stored_trade) + print("stored trade", stored_trade) + print("received event", dumps(data, indent=2)) if "old_state" in inside: + print("Old state is inside") if "new_state" in inside: + print("New state is inside") # We don't care unless we're being told a transaction is now completed if not inside["new_state"] == "completed": + print("New state is note completed, aborting") return # We don't care unless the existing trade is pending if not stored_trade["state"] == "pending": + print("State is not pending, aborting") return # Check the old state is what we also think it is if inside["old_state"] == stored_trade["state"]: + print("Old state is the state we think it should be") # Set the state to the new state stored_trade["state"] = inside["new_state"] # Store the updated state r.hmset(f"tx.{txid}", stored_trade) # Check it's all been previously validated if "valid" not in stored_trade: + print("Valid not in stored trade") print("valid not in stored_trade", stored_trade) - if stored_trade["valid"] == 1: + if stored_trade["valid"] == "1": print("WOULD RELEASE ESCROW FROM SECONDARY NOTINSIDE UPDATE", stored_trade["trade_id"], stored_trade["txid"]) return # If type not in inside and we haven't hit any more returns