Skip to content

Commit

Permalink
DerivationRequestWithRange from QuantifiedUnindexDerivationPAth + Pth…
Browse files Browse the repository at this point in the history
…cOmp
  • Loading branch information
CyonAlexRDX committed Sep 26, 2024
1 parent 02e6c6d commit 5919337
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 0 additions & 6 deletions src/factor_instances_provider/derive_more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> {
Expand Down
14 changes: 6 additions & 8 deletions src/factor_instances_provider/next_derivation_index_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ impl NextDerivationIndexFromProfile {
let all_unsecurified_in_profile = self

Check warning on line 75 in src/factor_instances_provider/next_derivation_index_analyzer.rs

View check run for this annotation

Codecov / codecov/patch

src/factor_instances_provider/next_derivation_index_analyzer.rs#L75

Added line #L75 was not covered by tests
.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

Check warning on line 79 in src/factor_instances_provider/next_derivation_index_analyzer.rs

View check run for this annotation

Codecov / codecov/patch

src/factor_instances_provider/next_derivation_index_analyzer.rs#L79

Added line #L79 was not covered by tests
.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)

Check warning on line 83 in src/factor_instances_provider/next_derivation_index_analyzer.rs

View check run for this annotation

Codecov / codecov/patch

src/factor_instances_provider/next_derivation_index_analyzer.rs#L81-L83

Added lines #L81 - L83 were not covered by tests
.max();

max_or_none
.max()
}
};

Expand All @@ -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;

Check warning on line 101 in src/factor_instances_provider/next_derivation_index_analyzer.rs

View check run for this annotation

Codecov / codecov/patch

src/factor_instances_provider/next_derivation_index_analyzer.rs#L97-L101

Added lines #L97 - L101 were not covered by tests
next
}
Expand Down Expand Up @@ -128,8 +127,7 @@ impl NextIndexAssignerWithEphemeralLocalOffsets {
let from_profile = self

Check warning on line 127 in src/factor_instances_provider/next_derivation_index_analyzer.rs

View check run for this annotation

Codecov / codecov/patch

src/factor_instances_provider/next_derivation_index_analyzer.rs#L127

Added line #L127 was not covered by tests
.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);

Check warning on line 131 in src/factor_instances_provider/next_derivation_index_analyzer.rs

View check run for this annotation

Codecov / codecov/patch

src/factor_instances_provider/next_derivation_index_analyzer.rs#L130-L131

Added lines #L130 - L131 were not covered by tests

let from_local = self.ephemeral_local_offsets.write_next(unindexed_request);

Check warning on line 133 in src/factor_instances_provider/next_derivation_index_analyzer.rs

View check run for this annotation

Codecov / codecov/patch

src/factor_instances_provider/next_derivation_index_analyzer.rs#L133

Added line #L133 was not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Check warning on line 76 in src/recovery_securify_cache/helpers/unindex_derivation_request.rs

View check run for this annotation

Codecov / codecov/patch

src/recovery_securify_cache/helpers/unindex_derivation_request.rs#L75-L76

Added lines #L75 - L76 were not covered by tests
}
}
impl From<(QuantifiedUnindexDerivationRequest, HDPathValue)> for DerivationRequestWithRange {
fn from(value: (QuantifiedUnindexDerivationRequest, HDPathValue)) -> Self {
let (q, i) = value;

Check warning on line 81 in src/recovery_securify_cache/helpers/unindex_derivation_request.rs

View check run for this annotation

Codecov / codecov/patch

src/recovery_securify_cache/helpers/unindex_derivation_request.rs#L80-L81

Added lines #L80 - L81 were not covered by tests
Self::new(
Expand Down

0 comments on commit 5919337

Please sign in to comment.