mirror of https://github.com/bitcoin/bitcoin.git
wallet: Add m_cached_from_me to cache "from me" status
m_cached_from_me is used to track whether a transaction is "from me", i.e. has any inputs which belong to the wallet. This is held in memory only in the same way that a transaction's balances are.
This commit is contained in:
parent
609d265ebc
commit
113a422822
|
@ -195,7 +195,10 @@ void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
|
|||
|
||||
bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx)
|
||||
{
|
||||
return (CachedTxGetDebit(wallet, wtx, /*avoid_reuse=*/false) > 0);
|
||||
if (!wtx.m_cached_from_me.has_value()) {
|
||||
wtx.m_cached_from_me = wallet.IsFromMe(*wtx.tx);
|
||||
}
|
||||
return wtx.m_cached_from_me.value();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
|
|
|
@ -232,6 +232,8 @@ public:
|
|||
* CWallet::ComputeTimeSmart().
|
||||
*/
|
||||
unsigned int nTimeSmart;
|
||||
// Cached value for whether the transaction spends any inputs known to the wallet
|
||||
mutable std::optional<bool> m_cached_from_me{std::nullopt};
|
||||
int64_t nOrderPos; //!< position in ordered transaction list
|
||||
std::multimap<int64_t, CWalletTx*>::const_iterator m_it_wtxOrdered;
|
||||
|
||||
|
@ -339,6 +341,7 @@ public:
|
|||
m_amounts[CREDIT].Reset();
|
||||
fChangeCached = false;
|
||||
m_is_cache_empty = true;
|
||||
m_cached_from_me = std::nullopt;
|
||||
}
|
||||
|
||||
/** True if only scriptSigs are different */
|
||||
|
|
Loading…
Reference in New Issue