check if wallet is mixing and restart whirlpool client if necessary

This commit is contained in:
Craig Raw 2021-11-17 16:02:11 +02:00
parent dc65313313
commit ece786131e
3 changed files with 19 additions and 1 deletions

2
drongo

@ -1 +1 @@
Subproject commit 8e4924783224fc894b45855cdbd866981413db3b Subproject commit 3a061cb73ae318fcbe7ea1dcb0b670e78803d9fa

View file

@ -310,6 +310,17 @@ public class Whirlpool {
} }
} }
public void checkIfMixing() {
if(whirlpoolWalletService.whirlpoolWallet() == null) {
return;
}
if(isMixing() && !whirlpoolWalletService.whirlpoolWallet().isStarted()) {
log.warn("Wallet is not started, but mixingProperty is true");
WhirlpoolEventService.getInstance().post(new WalletStopEvent(whirlpoolWalletService.whirlpoolWallet()));
}
}
public boolean hasWallet() { public boolean hasWallet() {
return hdWallet != null; return hdWallet != null;
} }

View file

@ -182,6 +182,13 @@ public class WhirlpoolServices {
stopAllWhirlpool(); stopAllWhirlpool();
} }
@Subscribe
public void newBlock(NewBlockEvent event) {
for(Whirlpool whirlpool : whirlpoolMap.values()) {
whirlpool.checkIfMixing();
}
}
@Subscribe @Subscribe
public void walletOpened(WalletOpenedEvent event) { public void walletOpened(WalletOpenedEvent event) {
String walletId = event.getStorage().getWalletId(event.getWallet()); String walletId = event.getStorage().getWalletId(event.getWallet());