forc_node/local/
mod.rs

1pub mod cmd;
2
3use crate::{
4    chain_config::{check_and_update_chain_config, ChainConfig},
5    util::HumanReadableConfig,
6};
7use forc_tracing::println_green;
8use fuel_core::service::FuelService;
9
10/// Local is a local node suited for local development.
11/// By default, the node is in `debug` mode and the db used is `in-memory`.
12/// Returns `None` if this is a dry_run and no service created for fuel-core.
13pub async fn run(cmd: cmd::LocalCmd, dry_run: bool) -> anyhow::Result<Option<FuelService>> {
14    check_and_update_chain_config(ChainConfig::Local).await?;
15
16    let config = fuel_core::service::Config::from(cmd);
17
18    if dry_run {
19        // For dry run, display the configuration that would be used
20        println_green(&format!("{}", HumanReadableConfig::from(&config)));
21        return Ok(None);
22    }
23    println_green("Starting fuel-core service...");
24    let service = FuelService::new_node(config)
25        .await
26        .map_err(|e| anyhow::anyhow!("Failed to start fuel-core service: {}", e))?;
27
28    println_green(&format!("Service started on: {}", service.bound_address));
29    Ok(Some(service))
30}