MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / MergeAndDiff

Method MergeAndDiff

src/script/descriptor.cpp:3035–3074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3033}
3034
3035DescriptorCache DescriptorCache::MergeAndDiff(const DescriptorCache& other)
3036{
3037 DescriptorCache diff;
3038 for (const auto& parent_xpub_pair : other.GetCachedParentExtPubKeys()) {
3039 CExtPubKey xpub;
3040 if (GetCachedParentExtPubKey(parent_xpub_pair.first, xpub)) {
3041 if (xpub != parent_xpub_pair.second) {
3042 throw std::runtime_error(std::string(__func__) + ": New cached parent xpub does not match already cached parent xpub");
3043 }
3044 continue;
3045 }
3046 CacheParentExtPubKey(parent_xpub_pair.first, parent_xpub_pair.second);
3047 diff.CacheParentExtPubKey(parent_xpub_pair.first, parent_xpub_pair.second);
3048 }
3049 for (const auto& derived_xpub_map_pair : other.GetCachedDerivedExtPubKeys()) {
3050 for (const auto& derived_xpub_pair : derived_xpub_map_pair.second) {
3051 CExtPubKey xpub;
3052 if (GetCachedDerivedExtPubKey(derived_xpub_map_pair.first, derived_xpub_pair.first, xpub)) {
3053 if (xpub != derived_xpub_pair.second) {
3054 throw std::runtime_error(std::string(__func__) + ": New cached derived xpub does not match already cached derived xpub");
3055 }
3056 continue;
3057 }
3058 CacheDerivedExtPubKey(derived_xpub_map_pair.first, derived_xpub_pair.first, derived_xpub_pair.second);
3059 diff.CacheDerivedExtPubKey(derived_xpub_map_pair.first, derived_xpub_pair.first, derived_xpub_pair.second);
3060 }
3061 }
3062 for (const auto& lh_xpub_pair : other.GetCachedLastHardenedExtPubKeys()) {
3063 CExtPubKey xpub;
3064 if (GetCachedLastHardenedExtPubKey(lh_xpub_pair.first, xpub)) {
3065 if (xpub != lh_xpub_pair.second) {
3066 throw std::runtime_error(std::string(__func__) + ": New cached last hardened xpub does not match already cached last hardened xpub");
3067 }
3068 continue;
3069 }
3070 CacheLastHardenedExtPubKey(lh_xpub_pair.first, lh_xpub_pair.second);
3071 diff.CacheLastHardenedExtPubKey(lh_xpub_pair.first, lh_xpub_pair.second);
3072 }
3073 return diff;
3074}
3075
3076ExtPubKeyMap DescriptorCache::GetCachedParentExtPubKeys() const
3077{

Callers 2

TopUpWithDBMethod · 0.80

Tested by

no test coverage detected