Skip to content

Commit

Permalink
remove KeysCollectingClient
Browse files Browse the repository at this point in the history
  • Loading branch information
CyonAlexRDX committed Aug 27, 2024
1 parent 4b7844c commit 956db6b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 51 deletions.
39 changes: 36 additions & 3 deletions src/derivation/collector/keys_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,46 @@ impl KeysCollector {
self.dependencies.interactors.interactor_for(kind)
}

async fn use_factor_sources(
&self,
interactor: KeyDerivationInteractor,
factor_sources: IndexSet<HDFactorSource>,
) -> Result<()> {
match interactor {
KeyDerivationInteractor::Parallel(interactor) => {
// Prepare the request for the interactor
let request = self.request_for_parallel_interactor(
factor_sources
.into_iter()
.map(|f| f.factor_source_id())
.collect(),
)?;
let response = interactor.derive(request).await?;
self.process_batch_response(response)?;
}

KeyDerivationInteractor::Serial(interactor) => {
for factor_source in factor_sources {
// Prepare the request for the interactor
let request =
self.request_for_serial_interactor(&factor_source.factor_source_id())?;

// Produce the results from the interactor
let response = interactor.derive(request).await?;

// Report the results back to the collector
self.process_batch_response(response)?;
}
}
}
Ok(())
}

/// In decreasing "friction order"
async fn derive_with_factors(&self) -> Result<()> {
for factors_of_kind in self.dependencies.factors_of_kind.iter() {
let interactor = self.get_interactor(factors_of_kind.kind);
let client = KeysCollectingClient::new(interactor);
client
.use_factor_sources(factors_of_kind.factor_sources(), self)
self.use_factor_sources(interactor, factors_of_kind.factor_sources())
.await?;
}
Ok(())
Expand Down
46 changes: 0 additions & 46 deletions src/derivation/interactors/keys_collecting_client.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/derivation/interactors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mod keys_collecting_client;
mod keys_collecting_interactors;

pub use keys_collecting_client::*;
pub use keys_collecting_interactors::*;

0 comments on commit 956db6b

Please sign in to comment.