wallet: Use scriptPubKey cache in IsMine
This commit is contained in:
1 parent
37232332bd
commit
edf4e73a16
1 file changed
+15
-4
+15
-4
@@ -1571,11 +1571,22 @@ isminetype CWallet::IsMine(const CTxDestination& dest) const
|
|||||||
isminetype CWallet::IsMine(const CScript& script) const
|
isminetype CWallet::IsMine(const CScript& script) const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
isminetype result = ISMINE_NO;
|
|
||||||
for (const auto& spk_man_pair : m_spk_managers) {
|
// Search the cache so that IsMine is called only on the relevant SPKMs instead of on everything in m_spk_managers
|
||||||
result = std::max(result, spk_man_pair.second->IsMine(script));
|
const auto& it = m_cached_spks.find(script);
|
||||||
|
if (it != m_cached_spks.end()) {
|
||||||
|
isminetype res = ISMINE_NO;
|
||||||
|
for (const auto& spkm : it->second) {
|
||||||
|
res = std::max(res, spkm->IsMine(script));
|
||||||
|
}
|
||||||
|
Assume(res == ISMINE_SPENDABLE);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
// Legacy wallet
|
||||||
|
if (IsLegacy()) return GetLegacyScriptPubKeyMan()->IsMine(script);
|
||||||
|
|
||||||
|
return ISMINE_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::IsMine(const CTransaction& tx) const
|
bool CWallet::IsMine(const CTransaction& tx) const
|
||||||
|
|||||||
Reference in new issue
Block a user