From df27902577ed068961e03c750d5ba2361d95496c Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 14 Jan 2024 09:44:07 -0500 Subject: [PATCH] add HavenoUtils.isSeedNode() --- .../haveno/core/api/XmrConnectionService.java | 2 +- .../haveno/core/offer/OfferBookService.java | 30 +++++++++---------- .../java/haveno/core/trade/HavenoUtils.java | 4 +++ .../java/haveno/core/trade/TradeManager.java | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index d676edd0..0cc66c74 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -519,7 +519,7 @@ public final class XmrConnectionService { private void maybeStartLocalNode() { // skip if seed node - if (HavenoUtils.havenoSetup == null) return; + if (HavenoUtils.isSeedNode()) return; // start local node if offline and used as last connection if (connectionManager.getConnection() != null && xmrLocalNode.equalsUri(connectionManager.getConnection().getUri()) && !xmrLocalNode.isDetected() && !xmrLocalNode.shouldBeIgnored()) { diff --git a/core/src/main/java/haveno/core/offer/OfferBookService.java b/core/src/main/java/haveno/core/offer/OfferBookService.java index 5492c355..8b7f5018 100644 --- a/core/src/main/java/haveno/core/offer/OfferBookService.java +++ b/core/src/main/java/haveno/core/offer/OfferBookService.java @@ -121,21 +121,21 @@ public class OfferBookService { @Override public void onRemoved(Collection protectedStorageEntries) { - protectedStorageEntries.forEach(protectedStorageEntry -> { - synchronized (offerBookChangedListeners) { - offerBookChangedListeners.forEach(listener -> { - if (protectedStorageEntry.getProtectedStoragePayload() instanceof OfferPayload) { - OfferPayload offerPayload = (OfferPayload) protectedStorageEntry.getProtectedStoragePayload(); - maybeInitializeKeyImagePoller(); - keyImagePoller.removeKeyImages(offerPayload.getReserveTxKeyImages()); - Offer offer = new Offer(offerPayload); - offer.setPriceFeedService(priceFeedService); - setReservedFundsSpent(offer); - listener.onRemoved(offer); - } - }); - } - }); + protectedStorageEntries.forEach(protectedStorageEntry -> { + synchronized (offerBookChangedListeners) { + offerBookChangedListeners.forEach(listener -> { + if (protectedStorageEntry.getProtectedStoragePayload() instanceof OfferPayload) { + OfferPayload offerPayload = (OfferPayload) protectedStorageEntry.getProtectedStoragePayload(); + maybeInitializeKeyImagePoller(); + keyImagePoller.removeKeyImages(offerPayload.getReserveTxKeyImages()); + Offer offer = new Offer(offerPayload); + offer.setPriceFeedService(priceFeedService); + setReservedFundsSpent(offer); + listener.onRemoved(offer); + } + }); + } + }); } }); diff --git a/core/src/main/java/haveno/core/trade/HavenoUtils.java b/core/src/main/java/haveno/core/trade/HavenoUtils.java index 46134a99..1b2fc24a 100644 --- a/core/src/main/java/haveno/core/trade/HavenoUtils.java +++ b/core/src/main/java/haveno/core/trade/HavenoUtils.java @@ -74,6 +74,10 @@ public class HavenoUtils { public static ArbitrationManager arbitrationManager; public static HavenoSetup havenoSetup; + public static boolean isSeedNode() { + return havenoSetup == null; + } + // ----------------------- CONVERSION UTILS ------------------------------- public static BigInteger coinToAtomicUnits(Coin coin) { diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index eaa610b3..fb35ca78 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -428,7 +428,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi } // process after all wallets initialized - if (HavenoUtils.havenoSetup != null) { // null for seednode + if (!HavenoUtils.isSeedNode()) { // maybe remove trades on error for (Trade trade : tradesToMaybeRemoveOnError) {