From c362f47a21948bad145b25829946e9057642b562 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Sat, 8 Jun 2024 16:34:09 +0000 Subject: [PATCH] TorController: Rename onionServicePublishedLatchMap to pendingOnionServicePublishLatchMap --- .../main/java/bisq/tor/controller/TorController.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java index 31a625d772..fae516887c 100644 --- a/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java +++ b/network/tor/tor/src/main/java/bisq/tor/controller/TorController.java @@ -33,7 +33,7 @@ public class TorController implements BootstrapEventListener, HsDescEventListene @Getter private final Observable bootstrapEvent = new Observable<>(); - private final Map onionServicePublishedLatchMap = new ConcurrentHashMap<>(); + private final Map pendingOnionServicePublishLatchMap = new ConcurrentHashMap<>(); private Optional torControlProtocol = Optional.empty(); @@ -70,7 +70,7 @@ public void bootstrapTor() throws IOException { public void publish(TorKeyPair torKeyPair, int onionServicePort, int localPort) throws IOException, InterruptedException { String onionAddress = torKeyPair.getOnionAddress(); var onionServicePublishedLatch = new CountDownLatch(1); - onionServicePublishedLatchMap.put(onionAddress, onionServicePublishedLatch); + pendingOnionServicePublishLatchMap.put(onionAddress, onionServicePublishedLatch); subscribeToHsDescEvents(); TorControlProtocol torControlProtocol = getTorControlProtocol(); @@ -123,8 +123,11 @@ public void onHsDescEvent(HsDescEvent hsDescEvent) { log.info("Tor HS_DESC event: {}", hsDescEvent); if (hsDescEvent.getAction() == HsDescEvent.Action.UPLOADED) { String onionAddress = hsDescEvent.getHsAddress() + ".onion"; - CountDownLatch countDownLatch = onionServicePublishedLatchMap.get(onionAddress); - countDownLatch.countDown(); + CountDownLatch countDownLatch = pendingOnionServicePublishLatchMap.get(onionAddress); + if (countDownLatch != null) { + countDownLatch.countDown(); + pendingOnionServicePublishLatchMap.remove(onionAddress); + } } }