Skip to content

Commit 87ae30f

Browse files
committed
network flags for nakamoto replay block
1 parent 894a3b2 commit 87ae30f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

stackslib/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl StacksChainConfig {
110110
}
111111

112112
const STACKS_CHAIN_CONFIG_DEFAULT_MAINNET: LazyCell<StacksChainConfig> =
113-
LazyCell::new(StacksChainConfig::default_testnet);
113+
LazyCell::new(StacksChainConfig::default_mainnet);
114114

115115
/// Replay blocks from chainstate database
116116
/// Terminates on error using `process::exit()`

stackslib/src/main.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,31 @@ simulating a miner.
14711471
}
14721472

14731473
if argv[1] == "replay-naka-block" {
1474-
cli::command_replay_block_nakamoto(&argv[1..], None);
1474+
let chain_config =
1475+
if let Some(network_flag_ix) = argv.iter().position(|arg| arg == "--network") {
1476+
let Some(network_choice) = argv.get(network_flag_ix + 1) else {
1477+
eprintln!("Must supply network choice after `--network` option");
1478+
process::exit(1);
1479+
};
1480+
1481+
let network_config = match network_choice.as_str() {
1482+
"testnet" => cli::StacksChainConfig::default_testnet(),
1483+
"mainnet" => cli::StacksChainConfig::default_mainnet(),
1484+
other => {
1485+
eprintln!("Unknown network choice `{other}`");
1486+
process::exit(1);
1487+
}
1488+
};
1489+
1490+
argv.remove(network_flag_ix + 1);
1491+
argv.remove(network_flag_ix);
1492+
1493+
Some(network_config)
1494+
} else {
1495+
None
1496+
};
1497+
1498+
cli::command_replay_block_nakamoto(&argv[1..], chain_config.as_ref());
14751499
process::exit(0);
14761500
}
14771501

0 commit comments

Comments
 (0)