aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/scriptpubkeyman.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2021-04-22 13:24:02 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-06-24 13:49:22 -0400
commitcacc3910989c4f3d7afa530dbab042461426abce (patch)
tree8e08000af456482dbe18abf3df5f5fd4cb25db03 /src/wallet/scriptpubkeyman.cpp
parent0b4c8ef75cd03c8f0a8cfadb47e0fbcabe3c5e59 (diff)
Move DescriptorCache writing to WalletBatch
Instead of adhoc writing of the items in DescriptorCache, move it all into WalletBatch.
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r--src/wallet/scriptpubkeyman.cpp13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 63add22917..ec38265216 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -1807,17 +1807,8 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size)
}
// Merge and write the cache
DescriptorCache new_items = m_wallet_descriptor.cache.MergeAndDiff(temp_cache);
- for (const auto& parent_xpub_pair : new_items.GetCachedParentExtPubKeys()) {
- if (!batch.WriteDescriptorParentCache(parent_xpub_pair.second, id, parent_xpub_pair.first)) {
- throw std::runtime_error(std::string(__func__) + ": writing cache item failed");
- }
- }
- for (const auto& derived_xpub_map_pair : new_items.GetCachedDerivedExtPubKeys()) {
- for (const auto& derived_xpub_pair : derived_xpub_map_pair.second) {
- if (!batch.WriteDescriptorDerivedCache(derived_xpub_pair.second, id, derived_xpub_map_pair.first, derived_xpub_pair.first)) {
- throw std::runtime_error(std::string(__func__) + ": writing cache item failed");
- }
- }
+ if (!batch.WriteDescriptorCacheItems(id, new_items)) {
+ throw std::runtime_error(std::string(__func__) + ": writing cache items failed");
}
m_max_cached_index++;
}