mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-15 16:38:23 +01:00
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:
@@ -195,7 +195,10 @@ void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
|
|||||||
|
|
||||||
bool CachedTxIsFromMe(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)
|
// NOLINTNEXTLINE(misc-no-recursion)
|
||||||
|
|||||||
@@ -232,6 +232,8 @@ public:
|
|||||||
* CWallet::ComputeTimeSmart().
|
* CWallet::ComputeTimeSmart().
|
||||||
*/
|
*/
|
||||||
unsigned int nTimeSmart;
|
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
|
int64_t nOrderPos; //!< position in ordered transaction list
|
||||||
std::multimap<int64_t, CWalletTx*>::const_iterator m_it_wtxOrdered;
|
std::multimap<int64_t, CWalletTx*>::const_iterator m_it_wtxOrdered;
|
||||||
|
|
||||||
@@ -339,6 +341,7 @@ public:
|
|||||||
m_amounts[CREDIT].Reset();
|
m_amounts[CREDIT].Reset();
|
||||||
fChangeCached = false;
|
fChangeCached = false;
|
||||||
m_is_cache_empty = true;
|
m_is_cache_empty = true;
|
||||||
|
m_cached_from_me = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** True if only scriptSigs are different */
|
/** True if only scriptSigs are different */
|
||||||
|
|||||||
Reference in New Issue
Block a user