Fix race conditions in cleanup
This commit is contained in:
parent
6418c5ecca
commit
712a144467
|
@ -77,9 +77,8 @@ class Agora(object):
|
|||
current_trades = []
|
||||
for contact_id, contact in dash.items():
|
||||
reference = self.tx.tx_to_ref(contact_id)
|
||||
if not reference:
|
||||
reference = "not_set"
|
||||
current_trades.append(reference)
|
||||
if reference:
|
||||
current_trades.append(reference)
|
||||
buyer = contact["data"]["buyer"]["username"]
|
||||
amount = contact["data"]["amount"]
|
||||
amount_xmr = contact["data"]["amount_xmr"]
|
||||
|
@ -87,9 +86,11 @@ class Agora(object):
|
|||
if not contact["data"]["is_selling"]:
|
||||
continue
|
||||
if reference not in self.last_dash:
|
||||
self.tx.new_trade(contact_id, buyer, currency, amount, amount_xmr)
|
||||
reference = self.tx.new_trade(contact_id, buyer, currency, amount, amount_xmr)
|
||||
if reference:
|
||||
if reference not in current_trades:
|
||||
current_trades.append(reference)
|
||||
if send_irc:
|
||||
|
||||
self.irc.client.msg(self.irc.client.channel, f"AUTO {reference}: {buyer} {amount}{currency} {amount_xmr}XMR")
|
||||
|
||||
dash_tmp.append(f"{reference}: {buyer} {amount}{currency} {amount_xmr}XMR")
|
||||
|
@ -99,6 +100,8 @@ class Agora(object):
|
|||
for ref in list(self.last_dash): # We're removing from the list on the fly
|
||||
if ref not in current_trades:
|
||||
self.last_dash.remove(ref)
|
||||
if reference and reference not in current_trades:
|
||||
current_trades.append(reference)
|
||||
self.tx.cleanup(current_trades)
|
||||
return dash_tmp
|
||||
|
||||
|
|
|
@ -144,6 +144,10 @@ class Transactions(object):
|
|||
self.irc.client.msg(self.irc.client.channel, f"Generated reference for {trade_id}: {reference}")
|
||||
if settings.Agora.Send == "1":
|
||||
self.agora.agora.contact_message_post(trade_id, f"Hi! When sending the payment please use reference code: {reference}")
|
||||
if existing_ref:
|
||||
return convert(existing_ref)
|
||||
else:
|
||||
return reference
|
||||
|
||||
def find_tx(self, reference, amount):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue