Skip to content

Commit ea657fb

Browse files
committed
feat(client-cli): scaffold new command to convert ledger state snapshots
1 parent 52fff48 commit ea657fb

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

mithril-client-cli/src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod cardano_stake_distribution;
99
pub mod cardano_transaction;
1010
mod deprecation;
1111
pub mod mithril_stake_distribution;
12+
pub mod tools;
1213

1314
pub use deprecation::{DeprecatedCommand, Deprecation};
1415

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//! Tools commands
2+
//!
3+
//! Provides utility subcommands such as converting restored InMemory UTxO-HD ledger snapshot
4+
//! to different flavors (Legacy, LMDB).
5+
6+
mod snapshot_converter;
7+
8+
use mithril_client::MithrilResult;
9+
pub use snapshot_converter::*;
10+
11+
use clap::Subcommand;
12+
13+
/// Tools commands
14+
#[derive(Subcommand, Debug, Clone)]
15+
pub enum ToolsCommands {
16+
/// UTxO-HD related commands
17+
#[clap(subcommand, name = "utxo-hd")]
18+
UTxOHD(UTxOHDCommands),
19+
}
20+
21+
impl ToolsCommands {
22+
/// Execute Tools command
23+
pub async fn execute(&self) -> MithrilResult<()> {
24+
match self {
25+
Self::UTxOHD(cmd) => cmd.execute().await,
26+
}
27+
}
28+
}
29+
30+
/// UTxO-HD related commands
31+
#[derive(Subcommand, Debug, Clone)]
32+
pub enum UTxOHDCommands {
33+
/// Convert a restored `InMemory` ledger snapshot to another flavor.
34+
#[clap(arg_required_else_help = false)]
35+
SnapshotConverter(SnapshotConverterCommand),
36+
}
37+
38+
impl UTxOHDCommands {
39+
/// Execute UTxO-HD command
40+
pub async fn execute(&self) -> MithrilResult<()> {
41+
match self {
42+
Self::SnapshotConverter(cmd) => cmd.execute().await,
43+
}
44+
}
45+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use clap::Parser;
2+
3+
use mithril_client::MithrilResult;
4+
5+
#[derive(Parser, Debug, Clone)]
6+
pub struct SnapshotConverterCommand {}
7+
8+
impl SnapshotConverterCommand {
9+
/// Main command execution
10+
pub async fn execute(&self) -> MithrilResult<()> {
11+
todo!()
12+
}
13+
}

mithril-client-cli/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use mithril_client_cli::commands::{
1717
cardano_db::CardanoDbCommands, cardano_db_v2::CardanoDbV2Commands,
1818
cardano_stake_distribution::CardanoStakeDistributionCommands,
1919
cardano_transaction::CardanoTransactionCommands,
20-
mithril_stake_distribution::MithrilStakeDistributionCommands, DeprecatedCommand, Deprecation,
20+
mithril_stake_distribution::MithrilStakeDistributionCommands, tools::ToolsCommands,
21+
DeprecatedCommand, Deprecation,
2122
};
2223
use mithril_client_cli::{ClapError, CommandContext};
2324

@@ -209,6 +210,9 @@ enum ArtifactCommands {
209210

210211
#[clap(alias("doc"), hide(true))]
211212
GenerateDoc(GenerateDocCommands),
213+
214+
#[clap(subcommand)]
215+
Tools(ToolsCommands),
212216
}
213217

214218
impl ArtifactCommands {
@@ -231,6 +235,7 @@ impl ArtifactCommands {
231235
Self::GenerateDoc(cmd) => cmd
232236
.execute(&mut Args::command())
233237
.map_err(|message| anyhow!(message)),
238+
Self::Tools(cmd) => cmd.execute().await,
234239
}
235240
}
236241

0 commit comments

Comments
 (0)