mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
restart whirlpool if no utxos mixing, bind debug logging accelerator
This commit is contained in:
parent
4554c9d0df
commit
39fa65ea37
2 changed files with 38 additions and 7 deletions
|
@ -315,12 +315,27 @@ public class Whirlpool {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isMixing() && !whirlpoolWalletService.whirlpoolWallet().isStarted()) {
|
if(isMixing()) {
|
||||||
log.warn("Wallet is not started, but mixingProperty is true");
|
if(!whirlpoolWalletService.whirlpoolWallet().isStarted()) {
|
||||||
WhirlpoolEventService.getInstance().post(new WalletStopEvent(whirlpoolWalletService.whirlpoolWallet()));
|
log.warn("Wallet is not started, but mixingProperty is true");
|
||||||
|
WhirlpoolEventService.getInstance().post(new WalletStopEvent(whirlpoolWalletService.whirlpoolWallet()));
|
||||||
|
} else if(whirlpoolWalletService.whirlpoolWallet().getMixingState().getUtxosMixing().isEmpty()) {
|
||||||
|
log.warn("No UTXOs mixing, but mixingProperty is true");
|
||||||
|
//Will automatically restart
|
||||||
|
AppServices.getWhirlpoolServices().stopWhirlpool(this, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void logDebug() {
|
||||||
|
if(whirlpoolWalletService.whirlpoolWallet() == null) {
|
||||||
|
log.warn("Whirlpool wallet for " + walletId + " not started");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn("Whirlpool debug for " + walletId + "\n" + whirlpoolWalletService.whirlpoolWallet().getDebug());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasWallet() {
|
public boolean hasWallet() {
|
||||||
return hdWallet != null;
|
return hdWallet != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,16 @@ import com.sparrowwallet.sparrow.event.*;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
import com.sparrowwallet.sparrow.io.Storage;
|
import com.sparrowwallet.sparrow.io.Storage;
|
||||||
import com.sparrowwallet.sparrow.net.TorService;
|
import com.sparrowwallet.sparrow.net.TorService;
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
import javafx.scene.input.KeyCodeCombination;
|
||||||
|
import javafx.scene.input.KeyCombination;
|
||||||
|
import javafx.stage.Window;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -65,6 +66,20 @@ public class WhirlpoolServices {
|
||||||
(Config.get().getProxyServer() == null || Config.get().getProxyServer().isEmpty() || !Config.get().isUseProxy() ? null : HostAndPort.fromString(Config.get().getProxyServer()));
|
(Config.get().getProxyServer() == null || Config.get().getProxyServer().isEmpty() || !Config.get().isUseProxy() ? null : HostAndPort.fromString(Config.get().getProxyServer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void bindDebugAccelerator() {
|
||||||
|
List<Window> windows = whirlpoolMap.keySet().stream().map(walletId -> AppServices.get().getWindowForWallet(walletId)).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
|
for(Window window : windows) {
|
||||||
|
KeyCombination keyCombination = new KeyCodeCombination(KeyCode.W, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN, KeyCombination.ALT_DOWN);
|
||||||
|
if(!window.getScene().getAccelerators().containsKey(keyCombination)) {
|
||||||
|
window.getScene().getAccelerators().put(keyCombination, () -> {
|
||||||
|
for(Whirlpool whirlpool : whirlpoolMap.values()) {
|
||||||
|
whirlpool.logDebug();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void startAllWhirlpool() {
|
private void startAllWhirlpool() {
|
||||||
for(Map.Entry<String, Whirlpool> entry : whirlpoolMap.entrySet().stream().filter(entry -> entry.getValue().hasWallet() && !entry.getValue().isStarted()).collect(Collectors.toList())) {
|
for(Map.Entry<String, Whirlpool> entry : whirlpoolMap.entrySet().stream().filter(entry -> entry.getValue().hasWallet() && !entry.getValue().isStarted()).collect(Collectors.toList())) {
|
||||||
Wallet wallet = AppServices.get().getWallet(entry.getKey());
|
Wallet wallet = AppServices.get().getWallet(entry.getKey());
|
||||||
|
@ -175,6 +190,7 @@ public class WhirlpoolServices {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void newConnection(ConnectionEvent event) {
|
public void newConnection(ConnectionEvent event) {
|
||||||
startAllWhirlpool();
|
startAllWhirlpool();
|
||||||
|
bindDebugAccelerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
Loading…
Reference in a new issue