Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/dfx/src/commands/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use crate::config::dfinity::ConfigDefaultsReplica;
use crate::lib::environment::Environment;
use crate::lib::error::{DfxError, DfxResult};
use crate::lib::message::UserMessage;
use crate::lib::replica_config::{
HttpHandlerConfig, ReplicaConfig, SchedulerConfig, StateManagerConfig,
};
use crate::lib::replica_config::{HttpHandlerConfig, ReplicaConfig, SchedulerConfig};

use clap::{App, Arg, ArgMatches, SubCommand};
use crossbeam::channel::{Receiver, Sender};
Expand Down Expand Up @@ -61,14 +59,11 @@ fn get_config(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult<Replica
round_gas_max: Some(round_gas_limit),
}
.validate()?;
let state_manager = StateManagerConfig {
state_root: env.get_state_dir(),
};
Ok(ReplicaConfig {
http_handler,
scheduler,
state_manager,
})

let mut replica_config = ReplicaConfig::new(env.get_state_dir());
replica_config.http_handler = http_handler;
replica_config.scheduler = scheduler;
Ok(replica_config)
}

/// Gets the configuration options for the Internet Computer replica as they were specified in the
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
let request_stop_echo = request_stop.clone();
let rcv_wait_fwatcher = rcv_wait.clone();
b.set_message("Generating IC local replica configuration.");
let replica_config = ReplicaConfig::new(&state_root)
let replica_config = ReplicaConfig::new(state_root)
.with_random_port(&client_port_path)
.to_toml()?;

Expand Down
22 changes: 20 additions & 2 deletions src/dfx/src/lib/replica_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ impl SchedulerConfig {
}
}

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct ArtifactPoolConfig {
pub consensus_pool_path: PathBuf,
}

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct CryptoConfig {
pub crypto_root: PathBuf,
}

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct StateManagerConfig {
pub state_root: PathBuf,
Expand All @@ -43,10 +53,12 @@ pub struct ReplicaConfig {
pub http_handler: HttpHandlerConfig,
pub scheduler: SchedulerConfig,
pub state_manager: StateManagerConfig,
pub crypto: CryptoConfig,
pub artifact_pool: ArtifactPoolConfig,
}

impl ReplicaConfig {
pub fn new(state_root: &Path) -> Self {
pub fn new(state_root: PathBuf) -> Self {
ReplicaConfig {
http_handler: HttpHandlerConfig {
write_port_to: None,
Expand All @@ -57,7 +69,13 @@ impl ReplicaConfig {
round_gas_max: None,
},
state_manager: StateManagerConfig {
state_root: state_root.to_path_buf(),
state_root: state_root.join("replicated_state"),
},
crypto: CryptoConfig {
crypto_root: state_root.join("crypto_store"),
},
artifact_pool: ArtifactPoolConfig {
consensus_pool_path: state_root.join("consensus_pool"),
},
}
}
Expand Down