mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-30 23:02:15 +00:00
Don't invoke onCoinsSent for cases when the balance doesn't change, just onWalletChanged directly.
Also implement equals/hashCodes for SaveRequest. Resolves a couple of FindBugs warnings.
This commit is contained in:
parent
1a5f74a148
commit
3ae65f7a2f
@ -485,6 +485,20 @@ public class Wallet implements Serializable, BlockChainListener {
|
||||
long delta = getDelay(TimeUnit.MILLISECONDS) - delayed.getDelay(TimeUnit.MILLISECONDS);
|
||||
return (delta > 0 ? 1 : (delta < 0 ? -1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof WalletSaveRequest)) return false;
|
||||
WalletSaveRequest w = (WalletSaveRequest) obj;
|
||||
return w.startTimeMs == startTimeMs &&
|
||||
w.requestedDelayMs == requestedDelayMs &&
|
||||
w.wallet == wallet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(wallet, startTimeMs, requestedDelayMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,11 +1029,11 @@ public class Wallet implements Serializable, BlockChainListener {
|
||||
// coins from the wallet.
|
||||
if (diff > 0) {
|
||||
invokeOnCoinsReceived(tx, prevBalance, newBalance);
|
||||
} else if (diff == 0) {
|
||||
// Hack. Invoke onCoinsSent in order to let the client save the wallet. This needs to go away.
|
||||
} else if (diff < 0) {
|
||||
invokeOnCoinsSent(tx, prevBalance, newBalance);
|
||||
} else {
|
||||
invokeOnCoinsSent(tx, prevBalance, newBalance);
|
||||
// We have a transaction that didn't change our balance. Probably we sent coins between our own keys.
|
||||
invokeOnWalletChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user