Skip to content

Commit

Permalink
Merge pull request #1413 from input-output-hk/ensemble/1406/simplify-…
Browse files Browse the repository at this point in the history
…mithril-client-cli

Simplify `mithril-client` CLI
  • Loading branch information
dlachaume authored Dec 21, 2023
2 parents 25bb9a6 + 0b9ccf2 commit a06c2e0
Show file tree
Hide file tree
Showing 27 changed files with 709 additions and 370 deletions.
10 changes: 3 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CompiledBinaries from '../../../compiled-binaries.md'
Mithril client library can be used by Rust developers to use the Mithril network in their applications.

It is responsible for handling the different types of data certified by Mithril, and available through a Mithril aggregator:
- [**Snapshot**](../../../glossary.md#snapshot): list, get and download tarball.
- [**Snapshot**](../../../glossary.md#snapshot): list, get, download tarball and record statistics.
- [**Mithril stake distribution**](../../../glossary.md#stake-distribution): list and get.
- [**Certificate**](../../../glossary.md#certificate): list, get, and chain validation.

Expand Down Expand Up @@ -88,6 +88,10 @@ async fn main() -> mithril_client::MithrilResult<()> {
.snapshot()
.download_unpack(&snapshot, target_directory)
.await?;

if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
println!("Could not increment snapshot download statistics: {:?}", e);
}

let message = MessageBuilder::new()
.compute_snapshot_message(&certificate, target_directory)
Expand Down Expand Up @@ -142,6 +146,10 @@ async fn main() -> mithril_client::MithrilResult<()> {
.snapshot()
.download_unpack(&snapshot, target_directory)
.await?;

if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
println!("Could not increment snapshot download statistics: {:?}", e);
}

let message = MessageBuilder::new()
.compute_snapshot_message(&certificate, target_directory)
Expand Down
2 changes: 1 addition & 1 deletion examples/client-snapshot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "client-snapshot"
description = "Mithril client snapshot example"
version = "0.1.2"
version = "0.1.3"
authors = ["[email protected]", "[email protected]"]
documentation = "https://mithril.network/doc"
edition = "2021"
Expand Down
1 change: 1 addition & 0 deletions examples/client-snapshot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ In this example, the client interacts with a real aggregator on the network `tes
- verify a certificate chain
- compute a message for a Snapshot
- verify that the certificate signs the computed message
- increments snapshot download statistics

The crate [indicatif](https://docs.rs/indicatif/latest/indicatif/) is used to nicely report the progress to the console.

Expand Down
4 changes: 4 additions & 0 deletions examples/client-snapshot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ async fn main() -> MithrilResult<()> {
.download_unpack(&snapshot, &unpacked_dir)
.await?;

if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
println!("Could not increment snapshot download statistics: {:?}", e);
}

println!("Computing snapshot '{}' message ...", snapshot.digest);
let message = wait_spinner(
&progress_bar,
Expand Down
6 changes: 1 addition & 5 deletions mithril-client-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-client-cli"
version = "0.5.12"
version = "0.5.13"
description = "A Mithril Client"
authors = { workspace = true }
edition = { workspace = true }
Expand All @@ -23,7 +23,6 @@ assets = [["../target/release/mithril-client", "usr/bin/", "755"]]

[dependencies]
anyhow = "1.0.75"
async-recursion = "1.0.5"
async-trait = "0.1.73"
chrono = { version = "0.4.31", features = ["serde"] }
clap = { version = "4.4.6", features = ["derive", "env"] }
Expand All @@ -37,8 +36,6 @@ mithril-client = { path = "../mithril-client", features = ["fs"] }
mithril-common = { path = "../mithril-common", features = ["full"] }
openssl = { version = "0.10.57", features = ["vendored"], optional = true }
openssl-probe = { version = "0.1.5", optional = true }
reqwest = { version = "0.11.22", features = ["json", "stream"] }
semver = "1.0.19"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
slog = { version = "2.7.0", features = [
Expand All @@ -54,7 +51,6 @@ tokio = { version = "1.32.0", features = ["full"] }

[dev-dependencies]
mithril-common = { path = "../mithril-common", features = ["test_http_server"] }
warp = "0.3"

[features]
portable = ["mithril-common/portable"]
Expand Down
Loading

0 comments on commit a06c2e0

Please sign in to comment.