add HavenoUtils.isSeedNode()

This commit is contained in:
woodser 2024-01-14 09:44:07 -05:00
parent 1a981f28df
commit df27902577
4 changed files with 21 additions and 17 deletions

View File

@ -519,7 +519,7 @@ public final class XmrConnectionService {
private void maybeStartLocalNode() { private void maybeStartLocalNode() {
// skip if seed node // skip if seed node
if (HavenoUtils.havenoSetup == null) return; if (HavenoUtils.isSeedNode()) return;
// start local node if offline and used as last connection // start local node if offline and used as last connection
if (connectionManager.getConnection() != null && xmrLocalNode.equalsUri(connectionManager.getConnection().getUri()) && !xmrLocalNode.isDetected() && !xmrLocalNode.shouldBeIgnored()) { if (connectionManager.getConnection() != null && xmrLocalNode.equalsUri(connectionManager.getConnection().getUri()) && !xmrLocalNode.isDetected() && !xmrLocalNode.shouldBeIgnored()) {

View File

@ -121,21 +121,21 @@ public class OfferBookService {
@Override @Override
public void onRemoved(Collection<ProtectedStorageEntry> protectedStorageEntries) { public void onRemoved(Collection<ProtectedStorageEntry> protectedStorageEntries) {
protectedStorageEntries.forEach(protectedStorageEntry -> { protectedStorageEntries.forEach(protectedStorageEntry -> {
synchronized (offerBookChangedListeners) { synchronized (offerBookChangedListeners) {
offerBookChangedListeners.forEach(listener -> { offerBookChangedListeners.forEach(listener -> {
if (protectedStorageEntry.getProtectedStoragePayload() instanceof OfferPayload) { if (protectedStorageEntry.getProtectedStoragePayload() instanceof OfferPayload) {
OfferPayload offerPayload = (OfferPayload) protectedStorageEntry.getProtectedStoragePayload(); OfferPayload offerPayload = (OfferPayload) protectedStorageEntry.getProtectedStoragePayload();
maybeInitializeKeyImagePoller(); maybeInitializeKeyImagePoller();
keyImagePoller.removeKeyImages(offerPayload.getReserveTxKeyImages()); keyImagePoller.removeKeyImages(offerPayload.getReserveTxKeyImages());
Offer offer = new Offer(offerPayload); Offer offer = new Offer(offerPayload);
offer.setPriceFeedService(priceFeedService); offer.setPriceFeedService(priceFeedService);
setReservedFundsSpent(offer); setReservedFundsSpent(offer);
listener.onRemoved(offer); listener.onRemoved(offer);
} }
}); });
} }
}); });
} }
}); });

View File

@ -74,6 +74,10 @@ public class HavenoUtils {
public static ArbitrationManager arbitrationManager; public static ArbitrationManager arbitrationManager;
public static HavenoSetup havenoSetup; public static HavenoSetup havenoSetup;
public static boolean isSeedNode() {
return havenoSetup == null;
}
// ----------------------- CONVERSION UTILS ------------------------------- // ----------------------- CONVERSION UTILS -------------------------------
public static BigInteger coinToAtomicUnits(Coin coin) { public static BigInteger coinToAtomicUnits(Coin coin) {

View File

@ -428,7 +428,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
} }
// process after all wallets initialized // process after all wallets initialized
if (HavenoUtils.havenoSetup != null) { // null for seednode if (!HavenoUtils.isSeedNode()) {
// maybe remove trades on error // maybe remove trades on error
for (Trade trade : tradesToMaybeRemoveOnError) { for (Trade trade : tradesToMaybeRemoveOnError) {