WalletTool: use an else branch rather than break (from a case)

This commit is contained in:
Andreas Schildbach 2023-05-24 10:33:11 +02:00
parent 021ace195f
commit d65aefd93e

View File

@ -945,22 +945,22 @@ public class WalletTool implements Callable<Integer> {
// Check if the balance already meets the given condition. // Check if the balance already meets the given condition.
if (condition.matchBitcoins(wallet.getBalance(Wallet.BalanceType.ESTIMATED))) { if (condition.matchBitcoins(wallet.getBalance(Wallet.BalanceType.ESTIMATED))) {
latch.countDown(); latch.countDown();
break; } else {
} Runnable onChange = () -> {
Runnable onChange = () -> { synchronized (this) {
synchronized (this) { saveWallet(walletFile);
saveWallet(walletFile); Coin balance = wallet.getBalance(Wallet.BalanceType.ESTIMATED);
Coin balance = wallet.getBalance(Wallet.BalanceType.ESTIMATED); if (condition.matchBitcoins(balance)) {
if (condition.matchBitcoins(balance)) { System.out.println(balance.toFriendlyString());
System.out.println(balance.toFriendlyString()); latch.countDown();
latch.countDown(); }
} }
} };
}; wallet.addCoinsReceivedEventListener((w, t, p, n) -> onChange.run());
wallet.addCoinsReceivedEventListener((w, t, p, n) -> onChange.run()); wallet.addCoinsSentEventListener((w, t, p, n) -> onChange.run());
wallet.addCoinsSentEventListener((w, t, p, n) -> onChange.run()); wallet.addChangeEventListener(w -> onChange.run());
wallet.addChangeEventListener(w -> onChange.run()); wallet.addReorganizeEventListener(w -> onChange.run());
wallet.addReorganizeEventListener(w -> onChange.run()); }
break; break;
} }