diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-04-22 13:24:02 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-06-24 13:49:22 -0400 |
commit | cacc3910989c4f3d7afa530dbab042461426abce (patch) | |
tree | 8e08000af456482dbe18abf3df5f5fd4cb25db03 /src/wallet/walletdb.cpp | |
parent | 0b4c8ef75cd03c8f0a8cfadb47e0fbcabe3c5e59 (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/walletdb.cpp')
-rw-r--r-- | src/wallet/walletdb.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 24d5351945..294fa3b8ee 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -248,6 +248,23 @@ bool WalletBatch::WriteDescriptorParentCache(const CExtPubKey& xpub, const uint2 return WriteIC(std::make_pair(std::make_pair(DBKeys::WALLETDESCRIPTORCACHE, desc_id), key_exp_index), ser_xpub); } +bool WalletBatch::WriteDescriptorCacheItems(const uint256& desc_id, const DescriptorCache& cache) +{ + for (const auto& parent_xpub_pair : cache.GetCachedParentExtPubKeys()) { + if (!WriteDescriptorParentCache(parent_xpub_pair.second, desc_id, parent_xpub_pair.first)) { + return false; + } + } + for (const auto& derived_xpub_map_pair : cache.GetCachedDerivedExtPubKeys()) { + for (const auto& derived_xpub_pair : derived_xpub_map_pair.second) { + if (!WriteDescriptorDerivedCache(derived_xpub_pair.second, desc_id, derived_xpub_map_pair.first, derived_xpub_pair.first)) { + return false; + } + } + } + return true; +} + class CWalletScanState { public: unsigned int nKeys{0}; |