Skip to content

Commit

Permalink
Add enable-capitalization-change flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Feb 13, 2024
1 parent 555ceec commit a59aa36
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,12 @@ fn main() {
.takes_value(true)
.help("Snapshot archive format to use.")
.conflicts_with("no_snapshot"),
)
.arg(
Arg::with_name("enable_capitalization_change")
.long("enable-capitalization-change")
.takes_value(false)
.help("If snapshot creation should succeed with a capitalization delta."),
),
)
.subcommand(
Expand Down Expand Up @@ -1806,6 +1812,9 @@ fn main() {
None
};

let enable_capitalization_change =
arg_matches.is_present("enable_capitalization_change");

let snapshot_type_str = if is_incremental {
"incremental "
} else if is_minimized {
Expand Down Expand Up @@ -2052,13 +2061,21 @@ fn main() {
bank.set_capitalization();

let post_capitalization = bank.capitalization();

if pre_capitalization != post_capitalization {
let amount = if pre_capitalization > post_capitalization {
format!("-{}", pre_capitalization - post_capitalization)
} else {
(post_capitalization - pre_capitalization).to_string()
};
warn!("Capitalization change: {amount} lamports");
let msg = format!("Capitalization change: {amount} lamports");
warn!("{msg}");
if !enable_capitalization_change {
eprintln!(
"{msg}\nBut `--enable-capitalization-change flag not provided"
);
exit(1);
}
}

let bank = if let Some(warp_slot) = warp_slot {
Expand Down

0 comments on commit a59aa36

Please sign in to comment.