Implement looking up references
This commit is contained in:
parent
64bf5a77ee
commit
bf4381caa6
|
@ -83,12 +83,18 @@ class Agora(object):
|
||||||
currency = contact["data"]["currency"]
|
currency = contact["data"]["currency"]
|
||||||
if not contact["data"]["is_selling"]:
|
if not contact["data"]["is_selling"]:
|
||||||
continue
|
continue
|
||||||
|
reference = self.tx.tx_to_ref(contact_id)
|
||||||
|
if not reference:
|
||||||
|
reference = "not_set"
|
||||||
if contact_id not in self.last_dash:
|
if contact_id not in self.last_dash:
|
||||||
self.tx.new_trade(contact_id, buyer, currency, amount, amount_xmr)
|
self.tx.new_trade(contact_id, buyer, currency, amount, amount_xmr)
|
||||||
if send_irc:
|
if send_irc:
|
||||||
self.irc.client.msg(self.irc.client.channel, f"AUTO {contact_id}: {buyer} {amount}{currency} {amount_xmr}XMR")
|
|
||||||
|
|
||||||
dash_tmp.append(f"{contact_id}: {buyer} {amount}{currency} {amount_xmr}XMR")
|
self.irc.client.msg(
|
||||||
|
self.irc.client.channel, f"AUTO {contact_id}: {buyer} {amount}{currency} {amount_xmr}XMR {reference}"
|
||||||
|
)
|
||||||
|
|
||||||
|
dash_tmp.append(f"{contact_id}: {buyer} {amount}{currency} {amount_xmr}XMR {reference}")
|
||||||
self.last_dash.add(contact_id)
|
self.last_dash.add(contact_id)
|
||||||
|
|
||||||
# Purge old trades from cache
|
# Purge old trades from cache
|
||||||
|
|
|
@ -113,9 +113,9 @@ class Transactions(object):
|
||||||
reference = "".join(choices(ascii_uppercase, k=5))
|
reference = "".join(choices(ascii_uppercase, k=5))
|
||||||
reference = f"XMR-{reference}"
|
reference = f"XMR-{reference}"
|
||||||
existing_ref = r.get(f"trade.{trade_id}.reference")
|
existing_ref = r.get(f"trade.{trade_id}.reference")
|
||||||
if existing_ref:
|
# if existing_ref:
|
||||||
self.irc.client.msg(self.irc.client.channel, f"Existing reference for {trade_id}: {existing_ref.decode('utf-8')}")
|
# self.irc.client.msg(self.irc.client.channel, f"Existing reference for {trade_id}: {existing_ref.decode('utf-8')}")
|
||||||
else:
|
if not existing_ref:
|
||||||
r.set(f"trade.{trade_id}.reference", reference)
|
r.set(f"trade.{trade_id}.reference", reference)
|
||||||
to_store = {
|
to_store = {
|
||||||
"id": trade_id,
|
"id": trade_id,
|
||||||
|
@ -185,7 +185,16 @@ class Transactions(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def tx_to_ref(self, tx):
|
def tx_to_ref(self, tx):
|
||||||
pass
|
refs = self.get_refs()
|
||||||
|
for reference in refs:
|
||||||
|
ref_data = convert(r.hgetall(f"trade.{reference}"))
|
||||||
|
if not ref_data:
|
||||||
|
continue
|
||||||
|
if ref_data["id"] == tx:
|
||||||
|
return reference
|
||||||
|
|
||||||
def ref_to_tx(self, reference):
|
def ref_to_tx(self, reference):
|
||||||
pass
|
ref_data = convert(r.hgetall(f"trade.{reference}"))
|
||||||
|
if not ref_data:
|
||||||
|
return False
|
||||||
|
return ref_data["id"]
|
||||||
|
|
Loading…
Reference in New Issue