Skip to content

Commit

Permalink
TorController: Rename onionServicePublishedLatchMap to pendingOnionSe…
Browse files Browse the repository at this point in the history
…rvicePublishLatchMap
  • Loading branch information
alvasw committed Jun 8, 2024
1 parent f9e9b21 commit c362f47
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class TorController implements BootstrapEventListener, HsDescEventListene
@Getter
private final Observable<BootstrapEvent> bootstrapEvent = new Observable<>();

private final Map<String, CountDownLatch> onionServicePublishedLatchMap = new ConcurrentHashMap<>();
private final Map<String, CountDownLatch> pendingOnionServicePublishLatchMap = new ConcurrentHashMap<>();

private Optional<TorControlProtocol> torControlProtocol = Optional.empty();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit c362f47

Please sign in to comment.