mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
wallet: Use scriptPubKey cache in GetScriptPubKeyMans
This commit is contained in:
parent
edf4e73a16
commit
b410f68791
1 changed files with 11 additions and 5 deletions
|
@ -3436,12 +3436,18 @@ ScriptPubKeyMan* CWallet::GetScriptPubKeyMan(const OutputType& type, bool intern
|
|||
std::set<ScriptPubKeyMan*> CWallet::GetScriptPubKeyMans(const CScript& script) const
|
||||
{
|
||||
std::set<ScriptPubKeyMan*> spk_mans;
|
||||
SignatureData sigdata;
|
||||
for (const auto& spk_man_pair : m_spk_managers) {
|
||||
if (spk_man_pair.second->CanProvide(script, sigdata)) {
|
||||
spk_mans.insert(spk_man_pair.second.get());
|
||||
}
|
||||
|
||||
// Search the cache for relevant SPKMs instead of iterating m_spk_managers
|
||||
const auto& it = m_cached_spks.find(script);
|
||||
if (it != m_cached_spks.end()) {
|
||||
spk_mans.insert(it->second.begin(), it->second.end());
|
||||
}
|
||||
SignatureData sigdata;
|
||||
Assume(std::all_of(spk_mans.begin(), spk_mans.end(), [&script, &sigdata](ScriptPubKeyMan* spkm) { return spkm->CanProvide(script, sigdata); }));
|
||||
|
||||
// Legacy wallet
|
||||
if (IsLegacy() && GetLegacyScriptPubKeyMan()->CanProvide(script, sigdata)) spk_mans.insert(GetLegacyScriptPubKeyMan());
|
||||
|
||||
return spk_mans;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue