fix mix event handling for multiple wallets

This commit is contained in:
Craig Raw 2021-08-24 09:29:54 +02:00
parent d1ab1db1c5
commit 615b78b497
2 changed files with 12 additions and 8 deletions

View file

@ -91,7 +91,7 @@ dependencies {
implementation('org.slf4j:jul-to-slf4j:1.7.30') { implementation('org.slf4j:jul-to-slf4j:1.7.30') {
exclude group: 'org.slf4j' exclude group: 'org.slf4j'
} }
implementation('com.sparrowwallet.nightjar:nightjar:0.2.9') implementation('com.sparrowwallet.nightjar:nightjar:0.2.10')
testImplementation('junit:junit:4.12') testImplementation('junit:junit:4.12')
} }
@ -387,7 +387,7 @@ extraJavaModuleInfo {
module('cbor-0.9.jar', 'co.nstant.in.cbor', '0.9') { module('cbor-0.9.jar', 'co.nstant.in.cbor', '0.9') {
exports('co.nstant.in.cbor') exports('co.nstant.in.cbor')
} }
module('nightjar-0.2.9.jar', 'com.sparrowwallet.nightjar', '0.2.9') { module('nightjar-0.2.10.jar', 'com.sparrowwallet.nightjar', '0.2.10') {
requires('com.google.common') requires('com.google.common')
requires('net.sourceforge.streamsupport') requires('net.sourceforge.streamsupport')
requires('org.slf4j') requires('org.slf4j')

View file

@ -344,10 +344,10 @@ public class Whirlpool {
@Subscribe @Subscribe
public void onMixSuccess(MixSuccessEvent e) { public void onMixSuccess(MixSuccessEvent e) {
log.debug("Mix success, new utxo " + e.getMixSuccess().getReceiveUtxo().getHash() + ":" + e.getMixSuccess().getReceiveUtxo().getIndex());
persistMixData();
WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo()); WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo());
if(walletUtxo != null) { if(walletUtxo != null) {
log.debug("Mix success, new utxo " + e.getMixSuccess().getReceiveUtxo().getHash() + ":" + e.getMixSuccess().getReceiveUtxo().getIndex());
persistMixData();
Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixSuccessEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixSuccess().getReceiveUtxo(), getReceiveNode(e, walletUtxo)))); Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixSuccessEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixSuccess().getReceiveUtxo(), getReceiveNode(e, walletUtxo))));
} }
} }
@ -364,30 +364,34 @@ public class Whirlpool {
@Subscribe @Subscribe
public void onMixFail(MixFailEvent e) { public void onMixFail(MixFailEvent e) {
log.debug("Mix failed for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getMixFailReason());
WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo()); WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo());
if(walletUtxo != null) { if(walletUtxo != null) {
log.debug("Mix failed for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getMixFailReason());
Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixFailReason()))); Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixFailReason())));
} }
} }
@Subscribe @Subscribe
public void onMixProgress(MixProgressEvent e) { public void onMixProgress(MixProgressEvent e) {
log.debug("Mix progress for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getWhirlpoolUtxo().getMixsDone() + " " + e.getMixProgress().getMixStep() + " " + e.getWhirlpoolUtxo().getUtxoState().getStatus());
WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo()); WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo());
if(walletUtxo != null && isMixing()) { if(walletUtxo != null && isMixing()) {
log.debug("Mix progress for utxo " + e.getWhirlpoolUtxo().getUtxo().tx_hash + ":" + e.getWhirlpoolUtxo().getUtxo().tx_output_n + " " + e.getWhirlpoolUtxo().getMixsDone() + " " + e.getMixProgress().getMixStep() + " " + e.getWhirlpoolUtxo().getUtxoState().getStatus());
Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixProgress()))); Platform.runLater(() -> EventManager.get().post(new WhirlpoolMixEvent(walletUtxo.wallet, walletUtxo.utxo, e.getMixProgress())));
} }
} }
@Subscribe @Subscribe
public void onWalletStart(WalletStartEvent e) { public void onWalletStart(WalletStartEvent e) {
mixingProperty.set(true); if(e.getWhirlpoolWallet() == whirlpoolWalletService.whirlpoolWallet()) {
mixingProperty.set(true);
}
} }
@Subscribe @Subscribe
public void onWalletStop(WalletStopEvent e) { public void onWalletStop(WalletStopEvent e) {
mixingProperty.set(false); if(e.getWhirlpoolWallet() == whirlpoolWalletService.whirlpoolWallet()) {
mixingProperty.set(false);
}
} }
public static class PoolsService extends Service<Collection<Pool>> { public static class PoolsService extends Service<Collection<Pool>> {