Merge branch 'haveno-dex:master' into haveno-reto

This commit is contained in:
boldsuck 2025-01-11 00:04:19 +01:00 committed by GitHub
commit 4666430429
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 200 additions and 217 deletions

View file

@ -1343,6 +1343,7 @@ public class XmrWalletService extends XmrWalletBase {
try {
doMaybeInitMainWallet(sync, MAX_SYNC_ATTEMPTS);
} catch (Exception e) {
if (isShutDownStarted) return;
log.warn("Error initializing main wallet: {}\n", e.getMessage(), e);
HavenoUtils.setTopError(e.getMessage());
throw e;
@ -1510,10 +1511,11 @@ public class XmrWalletService extends XmrWalletBase {
// try opening wallet
config.setNetworkType(getMoneroNetworkType());
config.setServer(connection);
log.info("Opening full wallet " + config.getPath() + " with monerod=" + connection.getUri() + ", proxyUri=" + connection.getProxyUri());
log.info("Opening full wallet '{}' with monerod={}, proxyUri={}", config.getPath(), connection.getUri(), connection.getProxyUri());
try {
walletFull = MoneroWalletFull.openWallet(config);
} catch (Exception e) {
if (isShutDownStarted) throw e;
log.warn("Failed to open full wallet '{}', attempting to use backup cache files, error={}", config.getPath(), e.getMessage());
boolean retrySuccessful = false;
try {
@ -1551,7 +1553,7 @@ public class XmrWalletService extends XmrWalletBase {
// retry opening wallet after cache deleted
try {
log.warn("Failed to open full wallet using backup cache files, retrying with cache deleted");
log.warn("Failed to open full wallet '{}' using backup cache files, retrying with cache deleted", config.getPath());
walletFull = MoneroWalletFull.openWallet(config);
log.warn("Successfully opened full wallet after cache deleted");
retrySuccessful = true;
@ -1565,7 +1567,7 @@ public class XmrWalletService extends XmrWalletBase {
} else {
// restore original wallet cache
log.warn("Failed to open full wallet after deleting cache, restoring original cache");
log.warn("Failed to open full wallet '{}' after deleting cache, restoring original cache", config.getPath());
File cacheFile = new File(cachePath);
if (cacheFile.exists()) cacheFile.delete();
if (originalCacheBackup.exists()) originalCacheBackup.renameTo(new File(cachePath));
@ -1637,11 +1639,12 @@ public class XmrWalletService extends XmrWalletBase {
if (!applyProxyUri) connection.setProxyUri(null);
// try opening wallet
log.info("Opening RPC wallet " + config.getPath() + " with monerod=" + connection.getUri() + ", proxyUri=" + connection.getProxyUri());
log.info("Opening RPC wallet '{}' with monerod={}, proxyUri={}", config.getPath(), connection.getUri(), connection.getProxyUri());
config.setServer(connection);
try {
walletRpc.openWallet(config);
} catch (Exception e) {
if (isShutDownStarted) throw e;
log.warn("Failed to open RPC wallet '{}', attempting to use backup cache files, error={}", config.getPath(), e.getMessage());
boolean retrySuccessful = false;
try {
@ -1679,7 +1682,7 @@ public class XmrWalletService extends XmrWalletBase {
// retry opening wallet after cache deleted
try {
log.warn("Failed to open RPC wallet using backup cache files, retrying with cache deleted");
log.warn("Failed to open RPC wallet '{}' using backup cache files, retrying with cache deleted", config.getPath());
walletRpc.openWallet(config);
log.warn("Successfully opened RPC wallet after cache deleted");
retrySuccessful = true;
@ -1693,7 +1696,7 @@ public class XmrWalletService extends XmrWalletBase {
} else {
// restore original wallet cache
log.warn("Failed to open RPC wallet after deleting cache, restoring original cache");
log.warn("Failed to open RPC wallet '{}' after deleting cache, restoring original cache", config.getPath());
File cacheFile = new File(cachePath);
if (cacheFile.exists()) cacheFile.delete();
if (originalCacheBackup.exists()) originalCacheBackup.renameTo(new File(cachePath));

View file

@ -424,7 +424,7 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
currencySelectionSubscriber = currencySelectionBinding.subscribe((observable, oldValue, newValue) -> {
});
tableView.setItems(model.getOfferList());
UserThread.execute(() -> tableView.setItems(model.getOfferList()));
model.getOfferList().addListener(offerListListener);
nrOfOffersLabel.setText(Res.get("offerbook.nrOffers", model.getOfferList().size()));
@ -788,13 +788,11 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
return new TableCell<>() {
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
if (item != null && !empty)
setGraphic(new ColoredDecimalPlacesWithZerosText(model.getAmount(item), GUIUtil.AMOUNT_DECIMALS_WITH_ZEROS));
else
setGraphic(null);
});
}
};
}
@ -819,13 +817,11 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
if (item != null && !empty)
setText(CurrencyUtil.getCurrencyPair(item.getOffer().getCurrencyCode()));
else
setText("");
});
}
};
}
@ -855,7 +851,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
return new TableCell<>() {
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
if (item != null && !empty) {
@ -863,7 +858,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
} else {
setGraphic(null);
}
});
}
private HBox getPriceAndPercentage(OfferBookListItem item) {
@ -939,7 +933,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
return new TableCell<>() {
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
if (item != null && !empty) {
@ -955,7 +948,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
setText("");
setGraphic(null);
}
});
}
};
}
@ -981,7 +973,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
if (item != null && !empty) {
@ -1006,7 +997,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
if (field != null)
field.setOnAction(null);
}
});
}
};
}
@ -1035,7 +1025,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
return new TableCell<>() {
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
if (item != null && !empty) {
@ -1056,7 +1045,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
setText("");
setGraphic(null);
}
});
}
};
}
@ -1083,7 +1071,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
final ImageView iconView = new ImageView();
@ -1190,7 +1177,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
tableRow.setOnMousePressed(null);
}
}
});
}
};
}
@ -1218,7 +1204,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
return new TableCell<>() {
@Override
public void updateItem(final OfferBookListItem item, boolean empty) {
UserThread.execute(() -> {
super.updateItem(item, empty);
if (item != null && !empty) {
@ -1230,7 +1215,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
} else {
setGraphic(null);
}
});
}
};
}
@ -1256,7 +1240,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
return new TableCell<>() {
@Override
public void updateItem(final OfferBookListItem newItem, boolean empty) {
UserThread.execute(() -> {
super.updateItem(newItem, empty);
if (newItem != null && !empty) {
final Offer offer = newItem.getOffer();
@ -1275,7 +1258,6 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
} else {
setGraphic(null);
}
});
}
};
}

View file

@ -277,9 +277,6 @@ public class BroadcastHandler implements PeerManager.Listener {
@Override
public void onFailure(@NotNull Throwable throwable) {
log.warn("Broadcast to " + connection.getPeersNodeAddressOptional() + " failed. ", throwable);
numOfFailedBroadcasts.incrementAndGet();
if (stopped.get()) {
return;
}
@ -356,7 +353,8 @@ public class BroadcastHandler implements PeerManager.Listener {
try {
future.cancel(true);
} catch (Exception e) {
if (!networkNode.isShutDownStarted()) throw e;
if (networkNode.isShutDownStarted()) return; // ignore if shut down
throw e;
}
});
sendMessageFutures.clear();