Skip to content

Commit a06c2e0

Browse files
authored
Merge pull request #1413 from input-output-hk/ensemble/1406/simplify-mithril-client-cli
Simplify `mithril-client` CLI
2 parents 25bb9a6 + 0b9ccf2 commit a06c2e0

27 files changed

+709
-370
lines changed

Cargo.lock

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/website/root/manual/developer-docs/nodes/mithril-client-library.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import CompiledBinaries from '../../../compiled-binaries.md'
1212
Mithril client library can be used by Rust developers to use the Mithril network in their applications.
1313

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

@@ -88,6 +88,10 @@ async fn main() -> mithril_client::MithrilResult<()> {
8888
.snapshot()
8989
.download_unpack(&snapshot, target_directory)
9090
.await?;
91+
92+
if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
93+
println!("Could not increment snapshot download statistics: {:?}", e);
94+
}
9195

9296
let message = MessageBuilder::new()
9397
.compute_snapshot_message(&certificate, target_directory)
@@ -142,6 +146,10 @@ async fn main() -> mithril_client::MithrilResult<()> {
142146
.snapshot()
143147
.download_unpack(&snapshot, target_directory)
144148
.await?;
149+
150+
if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
151+
println!("Could not increment snapshot download statistics: {:?}", e);
152+
}
145153

146154
let message = MessageBuilder::new()
147155
.compute_snapshot_message(&certificate, target_directory)

examples/client-snapshot/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "client-snapshot"
33
description = "Mithril client snapshot example"
4-
version = "0.1.2"
4+
version = "0.1.3"
55
66
documentation = "https://mithril.network/doc"
77
edition = "2021"

examples/client-snapshot/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ In this example, the client interacts with a real aggregator on the network `tes
1111
- verify a certificate chain
1212
- compute a message for a Snapshot
1313
- verify that the certificate signs the computed message
14+
- increments snapshot download statistics
1415

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

examples/client-snapshot/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ async fn main() -> MithrilResult<()> {
5555
.download_unpack(&snapshot, &unpacked_dir)
5656
.await?;
5757

58+
if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
59+
println!("Could not increment snapshot download statistics: {:?}", e);
60+
}
61+
5862
println!("Computing snapshot '{}' message ...", snapshot.digest);
5963
let message = wait_spinner(
6064
&progress_bar,

mithril-client-cli/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-client-cli"
3-
version = "0.5.12"
3+
version = "0.5.13"
44
description = "A Mithril Client"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -23,7 +23,6 @@ assets = [["../target/release/mithril-client", "usr/bin/", "755"]]
2323

2424
[dependencies]
2525
anyhow = "1.0.75"
26-
async-recursion = "1.0.5"
2726
async-trait = "0.1.73"
2827
chrono = { version = "0.4.31", features = ["serde"] }
2928
clap = { version = "4.4.6", features = ["derive", "env"] }
@@ -37,8 +36,6 @@ mithril-client = { path = "../mithril-client", features = ["fs"] }
3736
mithril-common = { path = "../mithril-common", features = ["full"] }
3837
openssl = { version = "0.10.57", features = ["vendored"], optional = true }
3938
openssl-probe = { version = "0.1.5", optional = true }
40-
reqwest = { version = "0.11.22", features = ["json", "stream"] }
41-
semver = "1.0.19"
4239
serde = { version = "1.0.188", features = ["derive"] }
4340
serde_json = "1.0.107"
4441
slog = { version = "2.7.0", features = [
@@ -54,7 +51,6 @@ tokio = { version = "1.32.0", features = ["full"] }
5451

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

5955
[features]
6056
portable = ["mithril-common/portable"]

0 commit comments

Comments
 (0)