Skip to content

Commit

Permalink
Return new_partial to be synchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed Jan 9, 2024
1 parent 5268b4f commit eb9058d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
20 changes: 10 additions & 10 deletions crates/humanode-peer/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub async fn run() -> sc_cli::Result<()> {
task_manager,
import_queue,
..
} = service::new_partial(&config).await?;
} = service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
.await
Expand All @@ -52,7 +52,7 @@ pub async fn run() -> sc_cli::Result<()> {
client,
task_manager,
..
} = service::new_partial(&config).await?;
} = service::new_partial(&config)?;
Ok((cmd.run(client, config.substrate.database), task_manager))
})
.await
Expand All @@ -65,7 +65,7 @@ pub async fn run() -> sc_cli::Result<()> {
client,
task_manager,
..
} = service::new_partial(&config).await?;
} = service::new_partial(&config)?;
Ok((cmd.run(client, config.substrate.chain_spec), task_manager))
})
.await
Expand All @@ -79,7 +79,7 @@ pub async fn run() -> sc_cli::Result<()> {
task_manager,
import_queue,
..
} = service::new_partial(&config).await?;
} = service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
.await
Expand All @@ -100,7 +100,7 @@ pub async fn run() -> sc_cli::Result<()> {
task_manager,
backend,
..
} = service::new_partial(&config).await?;
} = service::new_partial(&config)?;
let aux_revert = Box::new(|client, backend, blocks| {
sc_consensus_babe::revert(Arc::clone(&client), backend, blocks)?;
sc_consensus_grandpa::revert(client, blocks)?;
Expand Down Expand Up @@ -162,7 +162,7 @@ pub async fn run() -> sc_cli::Result<()> {
cmd.run::<Block, service::ExecutorDispatch>(config.substrate)
}
BenchmarkCmd::Block(cmd) => {
let partial = service::new_partial(&config).await?;
let partial = service::new_partial(&config)?;
cmd.run(partial.client)
}
#[cfg(not(feature = "runtime-benchmarks"))]
Expand All @@ -172,7 +172,7 @@ pub async fn run() -> sc_cli::Result<()> {
),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => {
let partial = service::new_partial(&config).await?;
let partial = service::new_partial(&config)?;
let db = partial.backend.expose_db();
let storage = partial.backend.expose_storage();

Expand All @@ -184,7 +184,7 @@ pub async fn run() -> sc_cli::Result<()> {
),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Overhead(cmd) => {
let partial = service::new_partial(&config).await?;
let partial = service::new_partial(&config)?;
let ext_builder = RemarkBuilder {
client: Arc::clone(&partial.client),
};
Expand All @@ -203,7 +203,7 @@ pub async fn run() -> sc_cli::Result<()> {
),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Extrinsic(cmd) => {
let partial = service::new_partial(&config).await?;
let partial = service::new_partial(&config)?;
let existential_deposit = <<Runtime as pallet_balances::Config>::ExistentialDeposit as Get<u128>>::get();
let ext_factory = ExtrinsicFactory(vec![
Box::new(RemarkBuilder {
Expand Down Expand Up @@ -233,7 +233,7 @@ pub async fn run() -> sc_cli::Result<()> {
let runner = root.create_humanode_runner(cmd)?;
runner
.async_run(|config| async move {
let partial = service::new_partial(&config).await?;
let partial = service::new_partial(&config)?;
let frontier_backend = match partial.other.4 {
fc_db::Backend::KeyValue(kv_fb) => Arc::new(kv_fb),
_ => {
Expand Down
7 changes: 3 additions & 4 deletions crates/humanode-peer/src/service/frontier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn db_config_dir(config: &sc_service::Configuration) -> std::path::PathBuf {
}

/// Create frontier backend.
pub async fn frontier_backend(
pub fn backend(
config: &Configuration,
client: Arc<FullClient>,
fb_config: &configuration::FrontierBackend,
Expand All @@ -40,7 +40,7 @@ pub async fn frontier_backend(
let db_path = db_config_dir(config).join("sql");
std::fs::create_dir_all(&db_path)?;

let backend = fc_db::sql::Backend::new(
let backend = futures::executor::block_on(fc_db::sql::Backend::new(
fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {
path: Path::new("sqlite:///")
.join(db_path)
Expand All @@ -54,8 +54,7 @@ pub async fn frontier_backend(
fb_config.frontier_sql_backend_pool_size,
std::num::NonZeroU32::new(fb_config.frontier_sql_backend_num_ops_timeout),
Arc::clone(&eth_overrides),
)
.await
))
.map_err(|err| ServiceError::Application(err.into()))?;

Ok(FrontierBackend::Sql(backend))
Expand Down
9 changes: 4 additions & 5 deletions crates/humanode-peer/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn keystore_container(
}

/// Extract substrate partial components.
pub async fn new_partial(
pub fn new_partial(
config: &Configuration,
) -> Result<
PartialComponents<
Expand Down Expand Up @@ -170,13 +170,12 @@ pub async fn new_partial(
Arc::clone(&client),
)?;

let frontier_backend = frontier::frontier_backend(
let frontier_backend = frontier::backend(
config,
Arc::clone(&client),
fronter_backend_config,
fc_storage::overrides_handle(Arc::clone(&client)),
)
.await?;
)?;

let frontier_block_import = FrontierBlockImport::new(babe_block_import, Arc::clone(&client));

Expand Down Expand Up @@ -237,7 +236,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
frontier_backend,
mut telemetry,
),
} = new_partial(&config).await?;
} = new_partial(&config)?;
let Configuration {
substrate: mut config,
bioauth_flow: bioauth_flow_config,
Expand Down
Empty file.

0 comments on commit eb9058d

Please sign in to comment.