From c548fdaf2934b9ffc4d8885f29c53fe0d1d78c09 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 26 Jul 2023 09:26:06 -0400 Subject: [PATCH] shutting down TorNetworkNode invokes callback handler if already complete --- Makefile | 9 ++++++++- core/src/main/java/haveno/core/trade/Trade.java | 2 +- .../java/haveno/core/trade/TradeManager.java | 5 +---- .../messages/DepositsConfirmedMessage.java | 1 - docs/developer-guide.md | 10 +++++----- .../network/p2p/network/TorNetworkNode.java | 17 +++++++++++------ 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 9d3d4394..869aa1f9 100644 --- a/Makefile +++ b/Makefile @@ -333,4 +333,11 @@ user3-desktop-stagenet: --nodePort=3103 \ --appName=haveno-XMR_STAGENET_user3 \ --apiPassword=apitest \ - --apiPort=3203 \ No newline at end of file + --apiPort=3203 + +# Mainnet network + +monerod: + ./.localnet/monerod \ + --bootstrap-daemon-address auto \ + --rpc-access-control-origins http://localhost:8080 \ \ No newline at end of file diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index 51704e23..9d23de58 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -1137,7 +1137,7 @@ public abstract class Trade implements Tradable, Model { } public void shutDown() { - if (wallet != null) log.info("{} {} shutting down", getClass().getSimpleName(), getId()); + if (!isPayoutUnlocked()) log.info("{} {} shutting down", getClass().getSimpleName(), getId()); synchronized (this) { isInitialized = false; isShutDown = true; diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index cc021219..c4d1e282 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -322,10 +322,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi private void closeAllTrades() { // collect trades to shutdown - Set trades = new HashSet(); - trades.addAll(tradableList.getList()); - trades.addAll(closedTradableManager.getClosedTrades()); - trades.addAll(failedTradesManager.getObservableList()); + List trades = getAllTrades(); // shut down trades in parallel Set tasks = new HashSet(); diff --git a/core/src/main/java/haveno/core/trade/messages/DepositsConfirmedMessage.java b/core/src/main/java/haveno/core/trade/messages/DepositsConfirmedMessage.java index 53fb5bdf..28c9b455 100644 --- a/core/src/main/java/haveno/core/trade/messages/DepositsConfirmedMessage.java +++ b/core/src/main/java/haveno/core/trade/messages/DepositsConfirmedMessage.java @@ -85,7 +85,6 @@ public final class DepositsConfirmedMessage extends TradeMailboxMessage { public String toString() { return "DepositsConfirmedMessage {" + "\n senderNodeAddress=" + senderNodeAddress + - ",\n pubKeyRing=" + pubKeyRing + ",\n sellerPaymentAccountKey=" + Utilities.bytesAsHexString(sellerPaymentAccountKey) + ",\n updatedMultisigHex=" + (updatedMultisigHex == null ? null : updatedMultisigHex.substring(0, Math.max(updatedMultisigHex.length(), 1000))) + "\n} " + super.toString(); diff --git a/docs/developer-guide.md b/docs/developer-guide.md index da669455..ff3b9aef 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -45,13 +45,13 @@ Follow [instructions](https://github.com/haveno-dex/haveno-ts#run-tests) to run ## Release portable Monero binaries for each platform -1. Update the release-v0.18 branch on Haveno's [monero repo](https://github.com/haveno-dex/monero) to the latest release from upstream + any customizations (e.g. a commit to speed up testnet hardforks for local development (b509b1)). -2. git tag testing12 && git push haveno testing12 +1. Update the release-v0.18 branch on Haveno's [monero repo](https://github.com/haveno-dex/monero) to the latest release from upstream + any customizations (e.g. a commit to speed up testnet hardforks for local development). +2. `git tag && git push haveno ` 3. Follow instructions to [build portable binaries for each platform](#build-portable-monero-binaries-for-each-platform). 4. Publish a new release at https://github.com/haveno-dex/monero/releases with the updated binaries and hashes. 5. Update the paths and hashes in build.gradle and PR. -## Build portable Monero binaries for each platform +### Build portable Monero binaries for each platform Based on these instructions: https://github.com/monero-project/monero#cross-compiling @@ -60,8 +60,8 @@ Based on these instructions: https://github.com/monero-project/monero#cross-comp 3. `sudo apt install cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev libtinfo5 autoconf libtool libtool-bin gperf` 4. `git clone https://github.com/haveno-dex/monero.git` 5. `cd ./monero (or rename this folder)` -6. `git submodule update --init --force` - +6. `git fetch origin && git reset --hard origin/release-v0.18` +7. `git submodule update --init --force` > Note: > If you get the prompt "Reversed (or previously applied) patch detected! Assume -R? [n]" then confirm 'y'. diff --git a/p2p/src/main/java/haveno/network/p2p/network/TorNetworkNode.java b/p2p/src/main/java/haveno/network/p2p/network/TorNetworkNode.java index d01e6c60..f0a622bd 100644 --- a/p2p/src/main/java/haveno/network/p2p/network/TorNetworkNode.java +++ b/p2p/src/main/java/haveno/network/p2p/network/TorNetworkNode.java @@ -58,6 +58,7 @@ public class TorNetworkNode extends NetworkNode { private boolean streamIsolation; private Socks5Proxy socksProxy; private boolean shutDownInProgress; + private boolean shutDownComplete; private final ExecutorService executor; /////////////////////////////////////////////////////////////////////////////////////////// @@ -121,17 +122,21 @@ public class TorNetworkNode extends NetworkNode { public void shutDown(@Nullable Runnable shutDownCompleteHandler) { log.info("TorNetworkNode shutdown started"); + if (shutDownComplete) { + log.info("TorNetworkNode shutdown already completed"); + if (shutDownCompleteHandler != null) shutDownCompleteHandler.run(); + return; + } if (shutDownInProgress) { - log.warn("We got shutDown already called"); + log.warn("Ignoring request to shut down because shut down is in progress"); return; } shutDownInProgress = true; shutDownTimeoutTimer = UserThread.runAfter(() -> { log.error("A timeout occurred at shutDown"); - if (shutDownCompleteHandler != null) - shutDownCompleteHandler.run(); - + shutDownComplete = true; + if (shutDownCompleteHandler != null) shutDownCompleteHandler.run(); executor.shutdownNow(); }, SHUT_DOWN_TIMEOUT); @@ -148,8 +153,8 @@ public class TorNetworkNode extends NetworkNode { log.error("Shutdown torNetworkNode failed with exception", e); } finally { shutDownTimeoutTimer.stop(); - if (shutDownCompleteHandler != null) - shutDownCompleteHandler.run(); + shutDownComplete = true; + if (shutDownCompleteHandler != null) shutDownCompleteHandler.run(); } }); }