From 591933709b828b66465e4bbb9f7b630115440e88 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Thu, 26 Sep 2024 11:03:29 +0200 Subject: [PATCH] DerivationRequestWithRange from QuantifiedUnindexDerivationPAth + PthcOmp --- src/factor_instances_provider/derive_more.rs | 6 ------ .../next_derivation_index_analyzer.rs | 14 ++++++-------- .../helpers/unindex_derivation_request.rs | 6 ++++++ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/factor_instances_provider/derive_more.rs b/src/factor_instances_provider/derive_more.rs index d5893202..eff16005 100644 --- a/src/factor_instances_provider/derive_more.rs +++ b/src/factor_instances_provider/derive_more.rs @@ -9,12 +9,6 @@ pub enum DeriveMore { WithoutKnownLastIndex(QuantifiedUnindexDerivationRequest), } impl DeriveMore { - pub fn requires_profile_index_assigner(&self) -> bool { - match self { - Self::WithKnownStartIndex { .. } => false, - Self::WithoutKnownLastIndex(_) => true, - } - } /// `None` for `WithoutKnownLastIndex`, only `Some` for `WithKnownStartIndex` /// where `if_partial_how_many_to_use_directly` is `Some` pub fn number_of_instances_needed_to_fully_satisfy_request(&self) -> Option { diff --git a/src/factor_instances_provider/next_derivation_index_analyzer.rs b/src/factor_instances_provider/next_derivation_index_analyzer.rs index fed70407..1cee35f2 100644 --- a/src/factor_instances_provider/next_derivation_index_analyzer.rs +++ b/src/factor_instances_provider/next_derivation_index_analyzer.rs @@ -75,14 +75,13 @@ impl NextDerivationIndexFromProfile { let all_unsecurified_in_profile = self .profile_snapshot .get_unsecurified_entities_of_kind_on_network(entity_kind, network_id); - let max_or_none = all_unsecurified_in_profile + + all_unsecurified_in_profile .into_iter() - .map(|ue| ue.veci().factor_instance()) + .map(|x: UnsecurifiedEntity| x.veci().factor_instance()) .filter(|fi| fi.matches(&unindexed_request)) .map(|fi| fi.derivation_path().index) - .max(); - - max_or_none + .max() } }; @@ -98,7 +97,7 @@ impl EphemeralLocalIndexOffsets { pub fn write_next(&self, request: UnquantifiedUnindexDerivationRequest) -> usize { let mut write = self.local_offsets.try_write().unwrap(); let entry = write.entry(request).or_insert(0); - let next = entry.clone(); + let next = *entry; *entry += 1; next } @@ -128,8 +127,7 @@ impl NextIndexAssignerWithEphemeralLocalOffsets { let from_profile = self .profile_offsets .as_ref() - .map(|p| p.read_next(unindexed_request.clone())) - .flatten() + .and_then(|p| p.read_next(unindexed_request.clone())) .unwrap_or(default); let from_local = self.ephemeral_local_offsets.write_next(unindexed_request); diff --git a/src/recovery_securify_cache/helpers/unindex_derivation_request.rs b/src/recovery_securify_cache/helpers/unindex_derivation_request.rs index 4ded3e36..572563a7 100644 --- a/src/recovery_securify_cache/helpers/unindex_derivation_request.rs +++ b/src/recovery_securify_cache/helpers/unindex_derivation_request.rs @@ -70,7 +70,13 @@ impl DerivationRequestWithRange { } } } + impl From<(QuantifiedUnindexDerivationRequest, HDPathComponent)> for DerivationRequestWithRange { + fn from(value: (QuantifiedUnindexDerivationRequest, HDPathComponent)) -> Self { + Self::from((value.0, value.1.base_index())) + } +} +impl From<(QuantifiedUnindexDerivationRequest, HDPathValue)> for DerivationRequestWithRange { fn from(value: (QuantifiedUnindexDerivationRequest, HDPathValue)) -> Self { let (q, i) = value; Self::new(