mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Move DescriptorCache writing to WalletBatch
Instead of adhoc writing of the items in DescriptorCache, move it all into WalletBatch.
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user