Browse Source

fix mix event handling for multiple wallets

terminal
Craig Raw 3 years ago
parent
commit
615b78b497
  1. 4
      build.gradle
  2. 16
      src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java

4
build.gradle

@ -91,7 +91,7 @@ dependencies {
implementation('org.slf4j:jul-to-slf4j:1.7.30') {
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')
}
@ -387,7 +387,7 @@ extraJavaModuleInfo {
module('cbor-0.9.jar', 'co.nstant.in.cbor', '0.9') {
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('net.sourceforge.streamsupport')
requires('org.slf4j')

16
src/main/java/com/sparrowwallet/sparrow/whirlpool/Whirlpool.java

@ -344,10 +344,10 @@ public class Whirlpool {
@Subscribe
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());
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))));
}
}
@ -364,30 +364,34 @@ public class Whirlpool {
@Subscribe
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());
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())));
}
}
@Subscribe
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());
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())));
}
}
@Subscribe
public void onWalletStart(WalletStartEvent e) {
mixingProperty.set(true);
if(e.getWhirlpoolWallet() == whirlpoolWalletService.whirlpoolWallet()) {
mixingProperty.set(true);
}
}
@Subscribe
public void onWalletStop(WalletStopEvent e) {
mixingProperty.set(false);
if(e.getWhirlpoolWallet() == whirlpoolWalletService.whirlpoolWallet()) {
mixingProperty.set(false);
}
}
public static class PoolsService extends Service<Collection<Pool>> {

Loading…
Cancel
Save