From a2c9a948f2d0a086d898231d4dedf638582fe0a7 Mon Sep 17 00:00:00 2001 From: Brooks Date: Tue, 21 Jan 2025 16:55:32 -0500 Subject: [PATCH] Adds --snapshot-zstd-compression-level to agave-ledger-tool (#4567) --- ledger-tool/src/main.rs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index f889587f3ba004..180b498e8f78a2 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -1448,6 +1448,20 @@ fn main() { .help("Snapshot archive format to use.") .conflicts_with("no_snapshot"), ) + .arg( + Arg::with_name("snapshot_zstd_compression_level") + .long("snapshot-zstd-compression-level") + .default_value("0") + .value_name("LEVEL") + .takes_value(true) + .help("The compression level to use when archiving with zstd") + .long_help( + "The compression level to use when archiving with zstd. \ + Higher compression levels generally produce higher \ + compression ratio at the expense of speed and memory. \ + See the zstd manpage for more information." + ), + ) .arg( Arg::with_name("enable_capitalization_change") .long("enable-capitalization-change") @@ -1970,9 +1984,18 @@ fn main() { let snapshot_archive_format = { let archive_format_str = value_t_or_exit!(arg_matches, "snapshot_archive_format", String); - ArchiveFormat::from_cli_arg(&archive_format_str).unwrap_or_else(|| { - panic!("Archive format not recognized: {archive_format_str}") - }) + let mut archive_format = ArchiveFormat::from_cli_arg(&archive_format_str) + .unwrap_or_else(|| { + panic!("Archive format not recognized: {archive_format_str}") + }); + if let ArchiveFormat::TarZstd { config } = &mut archive_format { + config.compression_level = value_t_or_exit!( + arg_matches, + "snapshot_zstd_compression_level", + i32 + ); + } + archive_format }; let genesis_config = open_genesis_config_by(&ledger_path, arg_matches);