From b70f14c399a61aad23b3a3507834561e693db972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=C3=ADn=20Dufka?= Date: Sat, 3 Aug 2024 23:55:01 +0200 Subject: [PATCH] add periodic coinjoin refresh --- manager.py | 22 +++----------------- manager/wasabi_clients/wasabi_client_base.py | 3 --- manager/wasabi_clients/wasabi_client_v1.py | 2 -- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/manager.py b/manager.py index 2629f59..718714e 100644 --- a/manager.py +++ b/manager.py @@ -356,30 +356,20 @@ def pay_invoices(addressed_invoices): def start_coinjoin(client): + sleep(random.random() / 10) client.start_coinjoin() - print( - f"- started mixing {client.name} (block {current_block}, round {current_round})" - ) def stop_coinjoin(client): + sleep(random.random() / 10) client.stop_coinjoin() - print( - f"- stopped mixing {client.name} (block {current_block}, round {current_round})" - ) def update_coinjoins(): def start_condition(client): - if client.active: - return False - return client.delay <= current_block and current_round not in client.skip_rounds def stop_condition(client): - if not client.active: - return False - return current_round in client.skip_rounds start = list(filter(start_condition, clients)) @@ -391,12 +381,6 @@ def stop_condition(client): with multiprocessing.pool.ThreadPool() as pool: pool.starmap(stop_coinjoin, ((client,) for client in stop)) - # client object are modified in different processes, so we need to update them manually - for client in start: - client.active = True - for client in stop: - client.active = False - def update_invoice_payments(): due = list( @@ -516,8 +500,8 @@ def run(): print(f"- could not get blocks".ljust(60), end="\r") print(f"Block exception: {e}", file=sys.stderr) - update_coinjoins() update_invoice_payments() + update_coinjoins() print( f"- coinjoin rounds: {current_round} (block {current_block})".ljust(60), end="\r", diff --git a/manager/wasabi_clients/wasabi_client_base.py b/manager/wasabi_clients/wasabi_client_base.py index 1e68736..ee31d01 100644 --- a/manager/wasabi_clients/wasabi_client_base.py +++ b/manager/wasabi_clients/wasabi_client_base.py @@ -21,7 +21,6 @@ def __init__( self.port = port self.name = name self.delay = delay - self.active = False self.proxy = proxy self.version = version self.skip_rounds = skip_rounds or list() @@ -131,14 +130,12 @@ def start_coinjoin(self): "method": "startcoinjoin", "params": ["", "True", "True"], } - self.active = True return self._rpc(request, timeout=None) def stop_coinjoin(self): request = { "method": "stopcoinjoin", } - self.active = False return self._rpc(request, "wallet") def list_coins(self): diff --git a/manager/wasabi_clients/wasabi_client_v1.py b/manager/wasabi_clients/wasabi_client_v1.py index fa7178a..de8b26b 100644 --- a/manager/wasabi_clients/wasabi_client_v1.py +++ b/manager/wasabi_clients/wasabi_client_v1.py @@ -83,10 +83,8 @@ def dequeue_all(self): def start_coinjoin(self): response = self.enqueue_all() - self.active = True return response def stop_coinjoin(self): response = self.dequeue_all() - self.active = False return response