Don't check non-exact values if we looked up without reference
This commit is contained in:
parent
19724eac77
commit
5ea1c26a84
|
@ -76,6 +76,8 @@ class Transactions(object):
|
||||||
self.log.info("Transaction processed: {formatted}", formatted=dumps(to_store, indent=2))
|
self.log.info("Transaction processed: {formatted}", formatted=dumps(to_store, indent=2))
|
||||||
r.hmset(f"tx.{txid}", to_store)
|
r.hmset(f"tx.{txid}", to_store)
|
||||||
self.irc.sendmsg(f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}")
|
self.irc.sendmsg(f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}")
|
||||||
|
|
||||||
|
# Partial reference implementation
|
||||||
# Account for silly people not removing the default string
|
# Account for silly people not removing the default string
|
||||||
# Split the reference into parts
|
# Split the reference into parts
|
||||||
ref_split = reference.split(" ")
|
ref_split = reference.split(" ")
|
||||||
|
@ -91,6 +93,9 @@ class Transactions(object):
|
||||||
print("Stored trade reference:", stored_trade_reference)
|
print("Stored trade reference:", stored_trade_reference)
|
||||||
|
|
||||||
stored_trade = False
|
stored_trade = False
|
||||||
|
looked_up_without_reference = False
|
||||||
|
|
||||||
|
# Amount/currency lookup implementation
|
||||||
if not stored_trade_reference:
|
if not stored_trade_reference:
|
||||||
self.log.info(f"No reference in DB refs for {reference}", reference=reference)
|
self.log.info(f"No reference in DB refs for {reference}", reference=reference)
|
||||||
self.irc.sendmsg(f"No reference in DB refs for {reference}")
|
self.irc.sendmsg(f"No reference in DB refs for {reference}")
|
||||||
|
@ -114,6 +119,8 @@ class Transactions(object):
|
||||||
self.irc.sendmsg(f"Not checking against amount and currency as amount exceeds MAX")
|
self.irc.sendmsg(f"Not checking against amount and currency as amount exceeds MAX")
|
||||||
# Close here if the amount exceeds the allowable limit for no reference
|
# Close here if the amount exceeds the allowable limit for no reference
|
||||||
return
|
return
|
||||||
|
# Note that we have looked it up without reference so we don't use +- below
|
||||||
|
looked_up_without_reference = True
|
||||||
if not stored_trade:
|
if not stored_trade:
|
||||||
stored_trade = self.get_ref(stored_trade_reference.pop())
|
stored_trade = self.get_ref(stored_trade_reference.pop())
|
||||||
print("Stored trade:", stored_trade)
|
print("Stored trade:", stored_trade)
|
||||||
|
@ -132,6 +139,8 @@ class Transactions(object):
|
||||||
|
|
||||||
# Make sure the expected amount was sent
|
# Make sure the expected amount was sent
|
||||||
if not stored_trade["amount"] == amount:
|
if not stored_trade["amount"] == amount:
|
||||||
|
if looked_up_without_reference:
|
||||||
|
return
|
||||||
# If the amount does not match exactly, get the min and max values for our given acceptable margins for trades
|
# If the amount does not match exactly, get the min and max values for our given acceptable margins for trades
|
||||||
min_amount, max_amount = self.agora.get_acceptable_margins(currency, amount)
|
min_amount, max_amount = self.agora.get_acceptable_margins(currency, amount)
|
||||||
self.irc.sendmsg(f"Amount does not match exactly, trying with margins: min: {min_amount} / max: {max_amount}")
|
self.irc.sendmsg(f"Amount does not match exactly, trying with margins: min: {min_amount} / max: {max_amount}")
|
||||||
|
|
Loading…
Reference in New Issue