Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
chore: align config upon creation
Browse files Browse the repository at this point in the history
  • Loading branch information
hadjiszs committed Aug 29, 2023
1 parent 374fa60 commit b6b1904
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 2 additions & 5 deletions crates/topos/src/components/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use tokio::{
use tokio_util::sync::CancellationToken;
use topos_p2p::config::NetworkConfig;
use topos_tce_transport::ReliableBroadcastParams;
use tracing::{error, info};
use tracing::{debug, error, info};
use tracing_opentelemetry::OpenTelemetrySpanExt;

use self::commands::{NodeCommand, NodeCommands};
Expand Down Expand Up @@ -133,7 +133,6 @@ pub(crate) async fn handle_command(

// FIXME: Handle properly the `cmd`
let config = NodeConfig::new(&node_path, None);
println!("EdgeConfig: {:?}", config.edge);
info!(
"⚙️ Reading the configuration from {}/{}/config.toml",
home.display(),
Expand Down Expand Up @@ -184,10 +183,8 @@ pub(crate) async fn handle_command(

// TCE
if config.base.subnet_id == "topos" {
let mut tce_config = config.tce.clone().unwrap();
tce_config.db_path = node_path.join(tce_config.db_path);
processes.push(services::spawn_tce_process(
tce_config,
config.tce.clone().unwrap(),
keys,
genesis,
(shutdown_token.clone(), shutdown_sender.clone()),
Expand Down
5 changes: 4 additions & 1 deletion crates/topos/src/components/node/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use topos_sequencer::SequencerConfiguration;
use topos_tce::config::{AuthKey, StorageConfiguration, TceConfiguration};
use topos_tce_transport::ReliableBroadcastParams;
use topos_wallet::SecretManager;
use tracing::{error, info, warn};
use tracing::{debug, error, info, warn};

use crate::config::genesis::Genesis;

Expand Down Expand Up @@ -77,6 +77,7 @@ pub(crate) fn spawn_sequencer_process(
verifier: 0,
};

debug!("Sequencer args: {config:?}");
spawn(async move {
topos_sequencer::run(config, shutdown).await.map_err(|e| {
error!("Failure on the Sequencer: {e:?}");
Expand Down Expand Up @@ -112,6 +113,7 @@ pub(crate) fn spawn_tce_process(
version: env!("TOPOS_VERSION"),
};

debug!("TCE args: {tce_config:?}");
spawn(async move {
topos_tce::run(&tce_config, shutdown).await.map_err(|e| {
error!("TCE process terminated: {e:?}");
Expand All @@ -126,6 +128,7 @@ pub fn spawn_edge_process(
genesis_path: PathBuf,
edge_args: HashMap<String, String>,
) -> JoinHandle<Result<(), Errors>> {
debug!("Edge args: {edge_args:?}");
spawn(async move {
match CommandConfig::new(edge_path)
.server(&data_dir, &genesis_path, edge_args)
Expand Down
9 changes: 8 additions & 1 deletion crates/topos/src/config/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl NodeConfig {
pub fn new(from: &Path, cmd: Option<node::commands::Init>) -> Self {
let base = load_config::<BaseConfig>(from, cmd);

Self {
let mut config = NodeConfig {
base: base.clone(),
sequencer: base
.need_sequencer()
Expand All @@ -45,7 +45,14 @@ impl NodeConfig {
edge: base
.need_edge()
.then(|| load_config::<EdgeConfig>(from, None)),
};

// Make the TCE DB path relative to the folder
if let Some(config) = config.tce.as_mut() {
config.db_path = from.join(&config.db_path);
}

config
}
}

Expand Down

0 comments on commit b6b1904

Please sign in to comment.