Skip to content

Commit

Permalink
new cli parameter --throttle-microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
p4bpj committed Jan 27, 2025
1 parent 6049c9b commit 8c8c648
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{net::IpAddr, str::FromStr};

#[derive(Debug, Parser)]
#[clap(about, version, author)]
#[clap(group(ArgGroup::new("throttle_group").args(&["throttle", "throttle_microseconds"])))]
#[clap(group(ArgGroup::new("required")))]
pub struct Opt {
#[clap(short, long, display_order = 3)]
Expand Down Expand Up @@ -39,9 +40,12 @@ pub struct Opt {
/// Mine even when kaspad says it is not synced, only useful when passing `--allow-submit-block-when-not-synced` to kaspad [default: false]
pub mine_when_not_synced: bool,
#[clap(long = "throttle", display_order = 9)]
/// Throttle (microseconds) between each pow hash generation (used for development testing)
/// Throttle (milliseconds) between each pow hash generation (used for development testing)
pub throttle: Option<u64>,
#[clap(long, display_order = 10)]
#[clap(long = "throttle-microseconds", display_order = 10)]
/// Throttle (microseconds) between each pow hash generation (used for development testing)
pub throttle_microseconds: Option<u64>,
#[clap(long, display_order = 11)]
/// Output logs in alternative format (same as kaspad)
pub altlogs: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async fn main() -> Result<(), Error> {
}
builder.init();

let throttle = opt.throttle.map(Duration::from_micros);
let throttle = opt.throttle.map(Duration::from_millis).or_else(|| opt.throttle_microseconds.map(Duration::from_micros));
let shutdown = ShutdownHandler(Arc::new(AtomicBool::new(false)));
let _shutdown_when_dropped = shutdown.arm();

Expand Down

0 comments on commit 8c8c648

Please sign in to comment.