diff --git a/src/cfg.rs b/src/cfg.rs index ef86643f..cb24143c 100644 --- a/src/cfg.rs +++ b/src/cfg.rs @@ -64,7 +64,7 @@ pub struct Config { #[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize)] #[cfg_attr(feature = "serde", derive(SerializeDisplay, DeserializeFromStr))] -enum DALayerOption { +pub enum DALayerOption { #[default] Celestia, #[cfg(test)] @@ -165,9 +165,7 @@ pub fn load_config(args: CommandLineArgs) -> Result } #[cfg(not(test))] -pub async fn initialize_da_layer( - config: &Config, -) -> Option> { +pub async fn initialize_da_layer(config: &Config) -> Arc { match &config.da_layer { DALayerOption::Celestia => { let celestia_conf = config.clone().celestia_config.unwrap(); @@ -178,20 +176,17 @@ pub async fn initialize_da_layer( ) .await { - Ok(da) => Some(Arc::new(da) as Arc), + Ok(da) => Arc::new(da) as Arc, Err(e) => { - error!("Failed to connect to Celestia: {}", e); - None + panic!("Failed to connect to Celestia: {}", e); } } } - DALayerOption::None => None, + DALayerOption::None => panic!("No DALayer"), } } #[cfg(test)] -pub async fn initialize_da_layer( - _config: &Config, -) -> Option> { - Some(Arc::new(LocalDataAvailabilityLayer::new()) as Arc) +pub async fn initialize_da_layer(_config: &Config) -> Arc { + Arc::new(LocalDataAvailabilityLayer::new()) as Arc } diff --git a/src/main.rs b/src/main.rs index 3e49a824..a33c087d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ mod cfg; +pub mod consts; pub mod da; pub mod error; mod node_types; @@ -44,7 +45,7 @@ async fn main() -> std::io::Result<()> { let node: Arc = match args.command { // LightClients need a DA layer, so we can unwrap here - Commands::LightClient {} => Arc::new(LightClient::new(da.unwrap(), config.public_key)), + Commands::LightClient {} => Arc::new(LightClient::new(da, config.public_key)), Commands::Sequencer {} => Arc::new(Sequencer::new( // TODO: convert error to std::io::Error...is there a better solution? Arc::new(