Transaction: remove the Android performance hack from getValue()

Mobile devices have become very powerful over the years, so a specific optimization
like this should not be needed.
This commit is contained in:
Andreas Schildbach 2022-07-16 11:13:23 +02:00
parent 9763a40a46
commit abc81d6d6e

View File

@ -480,23 +480,11 @@ public class Transaction extends ChildMessage {
return totalOut;
}
@Nullable private Coin cachedValue;
@Nullable private TransactionBag cachedForBag;
/**
* Returns the difference of {@link Transaction#getValueSentToMe(TransactionBag)} and {@link Transaction#getValueSentFromMe(TransactionBag)}.
*/
public Coin getValue(TransactionBag wallet) throws ScriptException {
// FIXME: TEMP PERF HACK FOR ANDROID - this crap can go away once we have a real payments API.
boolean isAndroid = Utils.isAndroidRuntime();
if (isAndroid && cachedValue != null && cachedForBag == wallet)
return cachedValue;
Coin result = getValueSentToMe(wallet).subtract(getValueSentFromMe(wallet));
if (isAndroid) {
cachedValue = result;
cachedForBag = wallet;
}
return result;
return getValueSentToMe(wallet).subtract(getValueSentFromMe(wallet));
}
/**