mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
prevent wallet response updates while whirlpool is starting
This commit is contained in:
parent
5959b00611
commit
6cf40e327c
2 changed files with 14 additions and 7 deletions
|
@ -319,7 +319,8 @@ public class Whirlpool {
|
||||||
if(!whirlpoolWalletService.whirlpoolWallet().isStarted()) {
|
if(!whirlpoolWalletService.whirlpoolWallet().isStarted()) {
|
||||||
log.warn("Wallet is not started, but mixingProperty is true");
|
log.warn("Wallet is not started, but mixingProperty is true");
|
||||||
WhirlpoolEventService.getInstance().post(new WalletStopEvent(whirlpoolWalletService.whirlpoolWallet()));
|
WhirlpoolEventService.getInstance().post(new WalletStopEvent(whirlpoolWalletService.whirlpoolWallet()));
|
||||||
} else if(whirlpoolWalletService.whirlpoolWallet().getMixingState().getUtxosMixing().isEmpty()) {
|
} else if(whirlpoolWalletService.whirlpoolWallet().getMixingState().getUtxosMixing().isEmpty() &&
|
||||||
|
!whirlpoolWalletService.whirlpoolWallet().getUtxoSupplier().findUtxos(WhirlpoolAccount.PREMIX, WhirlpoolAccount.POSTMIX).isEmpty()) {
|
||||||
log.warn("No UTXOs mixing, but mixingProperty is true");
|
log.warn("No UTXOs mixing, but mixingProperty is true");
|
||||||
//Will automatically restart
|
//Will automatically restart
|
||||||
AppServices.getWhirlpoolServices().stopWhirlpool(this, false);
|
AppServices.getWhirlpoolServices().stopWhirlpool(this, false);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.sparrowwallet.sparrow.event.WalletAddressesChangedEvent;
|
||||||
import com.sparrowwallet.sparrow.event.WalletHistoryChangedEvent;
|
import com.sparrowwallet.sparrow.event.WalletHistoryChangedEvent;
|
||||||
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
||||||
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
|
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
|
||||||
|
import javafx.application.Platform;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -246,12 +247,12 @@ public class SparrowDataSource extends WalletResponseDataSource {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void walletHistoryChanged(WalletHistoryChangedEvent event) {
|
public void walletHistoryChanged(WalletHistoryChangedEvent event) {
|
||||||
refreshWallet(event.getWalletId());
|
refreshWallet(event.getWalletId(), event.getWallet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void walletAddressesChanged(WalletAddressesChangedEvent event) {
|
public void walletAddressesChanged(WalletAddressesChangedEvent event) {
|
||||||
refreshWallet(event.getWalletId());
|
refreshWallet(event.getWalletId(), event.getWallet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -263,14 +264,19 @@ public class SparrowDataSource extends WalletResponseDataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshWallet(String eventWalletId) {
|
private void refreshWallet(String walletId, Wallet wallet) {
|
||||||
try {
|
try {
|
||||||
// match <prefix>:master, :Premix, :Postmix
|
// match <prefix>:master, :Premix, :Postmix
|
||||||
if (eventWalletId.startsWith(walletIdentifierPrefix)) {
|
if(walletId.startsWith(walletIdentifierPrefix) && (wallet.isWhirlpoolMasterWallet() || wallet.isWhirlpoolChildWallet())) {
|
||||||
refresh();
|
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(wallet);
|
||||||
|
if(whirlpool != null && whirlpool.isStarting()) {
|
||||||
|
Platform.runLater(() -> refreshWallet(walletId, wallet));
|
||||||
|
} else {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("", e);
|
log.error("Error refreshing wallet", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue