Skip to content

Commit

Permalink
Merge branch 'main' into rk/doc-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rklaehn committed Jul 5, 2024
2 parents 6541b28 + 2c40984 commit 66f4cd1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
34 changes: 18 additions & 16 deletions iroh-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Cli {
Commands::Console => {
let data_dir_owned = data_dir.to_owned();
if self.start {
let config = NodeConfig::load(self.config.as_deref()).await?;
let config = Self::load_config(self.config, self.metrics_port).await?;
start::run_with_command(
&config,
data_dir,
Expand All @@ -139,7 +139,7 @@ impl Cli {
Commands::Rpc(command) => {
let data_dir_owned = data_dir.to_owned();
if self.start {
let config = NodeConfig::load(self.config.as_deref()).await?;
let config = Self::load_config(self.config, self.metrics_port).await?;
start::run_with_command(
&config,
data_dir,
Expand All @@ -166,13 +166,7 @@ impl Cli {
path.display()
);
}
let mut config = NodeConfig::load(self.config.as_deref()).await?;
if let Some(metrics_port) = self.metrics_port {
config.metrics_addr = match metrics_port {
MetricsPort::Disabled => None,
MetricsPort::Port(port) => Some(([127, 0, 0, 1], port).into()),
};
}
let config = Self::load_config(self.config, self.metrics_port).await?;

let add_command = add.map(|source| blob::BlobCommands::Add {
source,
Expand All @@ -193,15 +187,23 @@ impl Cli {
.await
}
Commands::Doctor { command } => {
let mut config = NodeConfig::load(self.config.as_deref()).await?;
if let Some(metrics_port) = self.metrics_port {
config.metrics_addr = match metrics_port {
MetricsPort::Disabled => None,
MetricsPort::Port(port) => Some(([127, 0, 0, 1], port).into()),
};
}
let config = Self::load_config(self.config, self.metrics_port).await?;
self::doctor::run(command, &config).await
}
}
}

async fn load_config(
config: Option<PathBuf>,
metrics_port: Option<MetricsPort>,
) -> Result<NodeConfig> {
let mut config = NodeConfig::load(config.as_deref()).await?;
if let Some(metrics_port) = metrics_port {
config.metrics_addr = match metrics_port {
MetricsPort::Disabled => None,
MetricsPort::Port(port) => Some(([127, 0, 0, 1], port).into()),
};
}
Ok(config)
}
}
3 changes: 3 additions & 0 deletions iroh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
//! available over the network.
//!
//! ```rust
//! # async fn run() -> anyhow::Result<()> {
//! let node = iroh::node::Node::memory().spawn().await?;
//! let client = node.client();
//! let hash = client.blobs().add_bytes(b"some data".to_vec()).await?.hash;
//! println!("hash: {}", hash);
//! # Ok(())
//! # }
//! ```
//!
//! ## Explanation
Expand Down

0 comments on commit 66f4cd1

Please sign in to comment.