aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-02-02 14:16:49 -0500
committerAva Chow <github@achow101.com>2024-02-16 14:36:09 -0500
commit37232332bd7253422ea92a8c9eeb36b12fc84b56 (patch)
tree19762bc1f713fd35cf3e40608cac26ba1593bcb2 /src/wallet/wallet.cpp
parent99a0cddbc04e8bfea3748a6cb4c0107392fab94f (diff)
downloadbitcoin-37232332bd7253422ea92a8c9eeb36b12fc84b56.tar.xz
wallet: Cache scriptPubKeys for all DescriptorSPKMs
Have CWallet maintain a cache of all known scriptPubKeys for its DescriptorSPKMs in order to improve performance of the functions that require searching for scriptPubKeys.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index e98baeff54..a416276d05 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3891,6 +3891,8 @@ bool CWallet::ApplyMigrationData(MigrationData& data, bilingual_str& error)
if (ExtractDestination(script, dest)) not_migrated_dests.emplace(dest);
}
+ Assume(!m_cached_spks.empty());
+
for (auto& desc_spkm : data.desc_spkms) {
if (m_spk_managers.count(desc_spkm->GetID()) > 0) {
error = _("Error: Duplicate descriptors created during migration. Your wallet may be corrupted.");
@@ -4337,6 +4339,9 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
void CWallet::CacheNewScriptPubKeys(const std::set<CScript>& spks, ScriptPubKeyMan* spkm)
{
+ for (const auto& script : spks) {
+ m_cached_spks[script].push_back(spkm);
+ }
}
void CWallet::TopUpCallback(const std::set<CScript>& spks, ScriptPubKeyMan* spkm)