Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
CyonAlexRDX committed Sep 30, 2024
1 parent 8edc023 commit e4207c9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pre_derived_keys_cache/cache_outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub struct LoadFromCacheOutcomeForSingleRequest {
pub request: QuantifiedUnindexDerivationRequest,
outcome: LoadFromCacheOutcome,
}

impl LoadFromCacheOutcomeForSingleRequest {
/// # Panics
/// If FactorInstances is NOT empty inside the outcome, this ctor
Expand All @@ -84,12 +85,14 @@ impl LoadFromCacheOutcomeForSingleRequest {
outcome,
}
}

fn last_index_of(instances: &FactorInstances) -> HDPathValue {
assert!(!instances.is_empty());
let mut instances = instances.factor_instances().into_iter().collect_vec();
instances.sort_by_key(|instance| instance.derivation_entity_base_index());
instances.last().unwrap().derivation_entity_base_index()
}

pub fn action(&self) -> Action {
match self.outcome {
LoadFromCacheOutcome::FullySatisfiedWithSpare(ref from_cache) => {
Expand Down Expand Up @@ -143,6 +146,7 @@ pub struct FactorInstancesFromCache {
hidden: HiddenConstructor,
outcomes: Vec<LoadFromCacheOutcomeForSingleRequest>,
}

impl FactorInstancesFromCache {
pub fn new(iter: impl IntoIterator<Item = LoadFromCacheOutcomeForSingleRequest>) -> Self {
Self {
Expand All @@ -154,6 +158,7 @@ impl FactorInstancesFromCache {
.collect(),
}
}

pub fn outcomes(&self) -> IndexSet<LoadFromCacheOutcomeForSingleRequest> {
self.outcomes.clone().into_iter().collect()
}
Expand Down

0 comments on commit e4207c9

Please sign in to comment.