mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
minor whirlpool related fixes
This commit is contained in:
parent
37aa3c9712
commit
784fa5e1e8
4 changed files with 10 additions and 41 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 434c18ef0a97d899b534bf81496207542ebbd395
|
Subproject commit 360550a7183683ad4ee929a4c5411075bd751ffd
|
|
@ -18,7 +18,7 @@ import org.controlsfx.glyphfont.Glyph;
|
||||||
import org.controlsfx.tools.Platform;
|
import org.controlsfx.tools.Platform;
|
||||||
|
|
||||||
public class MixStatusCell extends TreeTableCell<Entry, UtxoEntry.MixStatus> {
|
public class MixStatusCell extends TreeTableCell<Entry, UtxoEntry.MixStatus> {
|
||||||
private static final int ERROR_DISPLAY_MINUTES = 5;
|
private static final int ERROR_DISPLAY_MILLIS = 5 * 60 * 1000;
|
||||||
|
|
||||||
public MixStatusCell() {
|
public MixStatusCell() {
|
||||||
super();
|
super();
|
||||||
|
@ -69,7 +69,8 @@ public class MixStatusCell extends TreeTableCell<Entry, UtxoEntry.MixStatus> {
|
||||||
|
|
||||||
private void setMixFail(MixFailReason mixFailReason, String mixError, Long mixErrorTimestamp) {
|
private void setMixFail(MixFailReason mixFailReason, String mixError, Long mixErrorTimestamp) {
|
||||||
if(mixFailReason != MixFailReason.CANCEL) {
|
if(mixFailReason != MixFailReason.CANCEL) {
|
||||||
if(mixErrorTimestamp != null && System.currentTimeMillis() - mixErrorTimestamp > ERROR_DISPLAY_MINUTES * 60 * 1000) {
|
long elapsed = mixErrorTimestamp == null ? 0L : System.currentTimeMillis() - mixErrorTimestamp;
|
||||||
|
if(elapsed >= ERROR_DISPLAY_MILLIS) {
|
||||||
//Old error, don't set again.
|
//Old error, don't set again.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -83,19 +84,13 @@ public class MixStatusCell extends TreeTableCell<Entry, UtxoEntry.MixStatus> {
|
||||||
"\nTo prevent sleeping, use the " + getPlatformSleepConfig() + " or enable the function in the Tools menu.");
|
"\nTo prevent sleeping, use the " + getPlatformSleepConfig() + " or enable the function in the Tools menu.");
|
||||||
setTooltip(tt);
|
setTooltip(tt);
|
||||||
|
|
||||||
double fromValue = 1.0;
|
FadeTransition ft = new FadeTransition(Duration.millis(ERROR_DISPLAY_MILLIS - elapsed), failGlyph);
|
||||||
if(mixErrorTimestamp != null) {
|
ft.setFromValue(1.0 - ((double)elapsed / ERROR_DISPLAY_MILLIS));
|
||||||
fromValue -= (double)(System.currentTimeMillis() - mixErrorTimestamp) / (ERROR_DISPLAY_MINUTES * 60 * 1000);
|
ft.setToValue(0.0);
|
||||||
}
|
|
||||||
|
|
||||||
FadeTransition ft = new FadeTransition(Duration.minutes(ERROR_DISPLAY_MINUTES), failGlyph);
|
|
||||||
ft.setFromValue(Math.max(0, fromValue));
|
|
||||||
ft.setToValue(0);
|
|
||||||
ft.setOnFinished(event -> {
|
ft.setOnFinished(event -> {
|
||||||
setTooltip(null);
|
setTooltip(null);
|
||||||
});
|
});
|
||||||
ft.play();
|
ft.play();
|
||||||
failGlyph.setUserData(mixFailReason);
|
|
||||||
} else {
|
} else {
|
||||||
setGraphic(null);
|
setGraphic(null);
|
||||||
setTooltip(null);
|
setTooltip(null);
|
||||||
|
|
|
@ -94,10 +94,6 @@ public class Whirlpool {
|
||||||
this.tx0Service = new Tx0Service(config);
|
this.tx0Service = new Tx0Service(config);
|
||||||
|
|
||||||
WhirlpoolEventService.getInstance().register(this);
|
WhirlpoolEventService.getInstance().register(this);
|
||||||
|
|
||||||
StatusReporterService statusReporterService = new StatusReporterService(this);
|
|
||||||
statusReporterService.setPeriod(Duration.minutes(1));
|
|
||||||
statusReporterService.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private WhirlpoolWalletConfig computeWhirlpoolWalletConfig(HostAndPort torProxy) {
|
private WhirlpoolWalletConfig computeWhirlpoolWalletConfig(HostAndPort torProxy) {
|
||||||
|
@ -744,30 +740,6 @@ public class Whirlpool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StatusReporterService extends ScheduledService<Boolean> {
|
|
||||||
private final Whirlpool whirlpool;
|
|
||||||
|
|
||||||
public StatusReporterService(Whirlpool whirlpool) {
|
|
||||||
this.whirlpool = whirlpool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Task<Boolean> createTask() {
|
|
||||||
return new Task<>() {
|
|
||||||
protected Boolean call() throws Exception {
|
|
||||||
if(whirlpool.mixingProperty().get()) {
|
|
||||||
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
|
|
||||||
log.debug(whirlpool.walletId + ": " + whirlpoolWallet.getMixingState());
|
|
||||||
} else {
|
|
||||||
log.debug(whirlpool.walletId + ": Not mixing");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class WalletUtxo {
|
public static class WalletUtxo {
|
||||||
public final Wallet wallet;
|
public final Wallet wallet;
|
||||||
public final BlockTransactionHashIndex utxo;
|
public final BlockTransactionHashIndex utxo;
|
||||||
|
|
|
@ -99,7 +99,6 @@ public class WhirlpoolServices {
|
||||||
startupService.cancel();
|
startupService.cancel();
|
||||||
});
|
});
|
||||||
startupService.setOnFailed(workerStateEvent -> {
|
startupService.setOnFailed(workerStateEvent -> {
|
||||||
log.error("Failed to start whirlpool", workerStateEvent.getSource().getException());
|
|
||||||
Throwable exception = workerStateEvent.getSource().getException();
|
Throwable exception = workerStateEvent.getSource().getException();
|
||||||
while(exception.getCause() != null) {
|
while(exception.getCause() != null) {
|
||||||
exception = exception.getCause();
|
exception = exception.getCause();
|
||||||
|
@ -109,6 +108,9 @@ public class WhirlpoolServices {
|
||||||
if(torProxy != null) {
|
if(torProxy != null) {
|
||||||
whirlpool.refreshTorCircuits();
|
whirlpool.refreshTorCircuits();
|
||||||
}
|
}
|
||||||
|
log.error("Error connecting to Whirlpool server: " + exception.getMessage());
|
||||||
|
} else {
|
||||||
|
log.error("Failed to start Whirlpool", workerStateEvent.getSource().getException());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
startupService.start();
|
startupService.start();
|
||||||
|
|
Loading…
Reference in a new issue