Skip to content

Commit

Permalink
add periodic coinjoin refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
dufkan committed Aug 4, 2024
1 parent 3a5c852 commit b70f14c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
22 changes: 3 additions & 19 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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(
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions manager/wasabi_clients/wasabi_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions manager/wasabi_clients/wasabi_client_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b70f14c

Please sign in to comment.