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() {
// 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()) {

View File

@ -121,21 +121,21 @@ public class OfferBookService {
@Override
public void onRemoved(Collection<ProtectedStorageEntry> 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);
}
});
}
});
}
});

View File

@ -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) {

View File

@ -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) {