Skip to content

Commit

Permalink
removed debug prints and changed `DerivationRequestQuantitySelector::…
Browse files Browse the repository at this point in the history
…FILL_CACHE_QUANTITY` back to `30`
  • Loading branch information
Sajjon committed Sep 28, 2024
1 parent cb6be47 commit c5b2286
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 90 deletions.
56 changes: 0 additions & 56 deletions src/factor_instances_provider/factor_instances_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,39 +166,6 @@ impl FactorInstancesProvider {
requests_with_ranges_with_abundance.extend(requests_to_satisfy_with_ranges);
requests_with_ranges_with_abundance.extend(fill_cache);

// for x in fill_cache.into_iter() {
// if let Some(request_with_range_without_abundance) =
// requests_to_satisfy_with_ranges.iter().find(|y| {
// let h = UnquantifiedUnindexDerivationRequest::from((*y).clone());
// UnquantifiedUnindexDerivationRequest::from(x.clone()) == h
// })
// {
// let request_with_range_with_abundance: DerivationRequestWithRange = {
// let quantity = 1 - 2;
// let start_base_index = 5 - 7;
// DerivationRequestWithRange::new(
// request_with_range_without_abundance.factor_source_id,
// request_with_range_without_abundance.network_id,
// request_with_range_without_abundance.entity_kind,
// request_with_range_without_abundance.key_kind,
// request_with_range_without_abundance.key_space,
// quantity,
// start_base_index,
// )
// };

// requests_with_ranges_with_abundance
// .insert(request_with_range_with_abundance.clone());

// requests_to_satisfy_with_ranges.swap_remove(request_with_range_without_abundance);
// } else {
// let next = next_index_assigner.next(x.clone().into());
// let request_with_range_with_abundance =
// DerivationRequestWithRange::from((x.clone(), next));
// requests_with_ranges_with_abundance.insert(request_with_range_with_abundance);
// }
// }

requests_with_ranges_with_abundance
.into_iter()
.into_group_map_by(|x| x.factor_source_id)
Expand Down Expand Up @@ -226,8 +193,6 @@ impl FactorInstancesProvider {
purpose.clone(),
);

println!("🚀 deriving more, derivation_paths: {:?}", derivation_paths);

let keys_collector = KeysCollector::new(
purpose.factor_sources(),
derivation_paths,
Expand Down Expand Up @@ -259,16 +224,9 @@ impl FactorInstancesProvider {

let to_cache = to_cache.into_iter().cloned().collect::<FactorInstances>();

println!(
"🍬⭐️ purpose: {:?}, using directly: {:?}, caching: {:?}",
purpose.clone(),
to_use_directly,
to_cache
);
NewlyDerived::maybe_some_to_use_directly(k, to_cache, to_use_directly)
} else {
let to_cache = v.into_iter().collect::<FactorInstances>();
println!("🍬🤷‍♀️ Caching #{} instances", to_cache.len());
NewlyDerived::cache_all(k, to_cache)
}
})
Expand Down Expand Up @@ -413,7 +371,6 @@ mod tests {
}

pub fn clear_cache(&self) {
println!("💣 clearing cache!!!");
*self.cache.try_write().unwrap() = PreDerivedKeysCache::default();
}

Expand All @@ -439,11 +396,6 @@ mod tests {
network: NetworkID,
name: impl AsRef<str>,
) -> Result<(Account, DidDeriveNewFactorInstances)> {
println!(
"🔮 ADDING ACCOUNT: '{}', number of accounts in profile: #{}",
name.as_ref(),
self.profile_snapshot().accounts.len()
);
let interactors: Arc<dyn KeysDerivationInteractors> =
Arc::new(TestDerivationInteractors::default());

Expand Down Expand Up @@ -676,14 +628,6 @@ mod tests {
let free_factor_instances_after_account_creation =
os.cache_snapshot().all_factor_instances();

println!(
"🐳 DEBUG printing cache: #{}",
os.cache_snapshot().all_factor_instances().len()
);
println!(
"🐳🐳🐳 DEBUG printing cache: {:?}",
os.cache_snapshot().all_factor_instances()
);
assert_eq!(
free_factor_instances_after_account_creation.len(),
(DerivationRequestQuantitySelector::FILL_CACHE_QUANTITY * 6 ) - 1,
Expand Down
35 changes: 2 additions & 33 deletions src/factor_instances_provider/next_derivation_index_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,12 @@ impl NextDerivationIndexFromProfile {
.profile_snapshot
.get_unsecurified_entities_of_kind_on_network(entity_kind, network_id);

println!(
"🎭🎭🎭 NextDerivationIndexFromProfile, all_unsecurified_in_profile: #{}",
all_unsecurified_in_profile.len()
);

let apor = all_unsecurified_in_profile
all_unsecurified_in_profile
.into_iter()
.map(|x: UnsecurifiedEntity| x.veci().factor_instance())
.filter(|fi| fi.matches(&unindexed_request))
.collect::<IndexSet<_>>();

println!(
"🎭🎭🎭 NextDerivationIndexFromProfile, apor: #{}",
apor.len()
);

let bananer = apor
.into_iter()
.map(|fi| fi.derivation_path().index)
.collect::<IndexSet<_>>();

println!(
"🎭🎭🎭 NextDerivationIndexFromProfile, bananer: {:?}",
bananer
);

bananer.into_iter().max()
.max()
}
};

Expand Down Expand Up @@ -151,20 +130,10 @@ impl NextIndexAssignerWithEphemeralLocalOffsets {
.and_then(|p| p.read_next(unindexed_request.clone()))
.unwrap_or(default);

println!(
"🎭 NextIndexAssignerWithEphemeralLocalOffs, from_profile: {}",
from_profile.base_index()
);

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

let next = from_profile.add_n(from_local as HDPathValue);

println!(
"🎭 NextIndexAssignerWithEphemeralLocalOffs, next: {:?}",
next
);

next
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub enum DerivationRequestQuantitySelector {
Poly { count: usize },
}
impl DerivationRequestQuantitySelector {
pub const FILL_CACHE_QUANTITY: usize = 3;
pub const FILL_CACHE_QUANTITY: usize = 30;
pub fn fill_cache_if_needed() -> Self {
DerivationRequestQuantitySelector::Poly {
count: Self::FILL_CACHE_QUANTITY,
Expand Down

0 comments on commit c5b2286

Please sign in to comment.