Skip to content

Commit adaabe6

Browse files
committed
use u32 for block_rejection_timeout_steps keys
1 parent d713290 commit adaabe6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

stackslib/src/config/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ pub struct MinerConfig {
21562156
/// Duration to wait before attempting to issue a tenure extend
21572157
pub tenure_timeout: Duration,
21582158
/// Define the timeout to apply while waiting for signers responses, based on the amount of rejections
2159-
pub block_rejection_timeout_steps: HashMap<u64, Duration>,
2159+
pub block_rejection_timeout_steps: HashMap<u32, Duration>,
21602160
}
21612161

21622162
impl Default for MinerConfig {
@@ -2196,7 +2196,7 @@ impl Default for MinerConfig {
21962196
tenure_extend_poll_secs: Duration::from_secs(DEFAULT_TENURE_EXTEND_POLL_SECS),
21972197
tenure_timeout: Duration::from_secs(DEFAULT_TENURE_TIMEOUT_SECS),
21982198
block_rejection_timeout_steps: {
2199-
let mut rejections_timeouts_default_map = HashMap::<u64, Duration>::new();
2199+
let mut rejections_timeouts_default_map = HashMap::<u32, Duration>::new();
22002200
rejections_timeouts_default_map.insert(0, Duration::from_secs(600));
22012201
rejections_timeouts_default_map.insert(10, Duration::from_secs(300));
22022202
rejections_timeouts_default_map.insert(20, Duration::from_secs(150));
@@ -2744,9 +2744,9 @@ impl MinerConfigFile {
27442744
tenure_timeout: self.tenure_timeout_secs.map(Duration::from_secs).unwrap_or(miner_default_config.tenure_timeout),
27452745
block_rejection_timeout_steps: {
27462746
if let Some(block_rejection_timeout_items) = self.block_rejection_timeout_steps {
2747-
let mut rejection_timeout_durations = HashMap::<u64, Duration>::new();
2747+
let mut rejection_timeout_durations = HashMap::<u32, Duration>::new();
27482748
for (slice, seconds) in block_rejection_timeout_items.iter() {
2749-
match slice.parse::<u64>() {
2749+
match slice.parse::<u32>() {
27502750
Ok(slice_slot) => rejection_timeout_durations.insert(slice_slot, Duration::from_secs(*seconds)),
27512751
Err(e) => panic!("block_rejection_timeout_steps keys must be unsigned integers: {}", e)
27522752
};

testnet/stacks-node/src/nakamoto_node/signer_coordinator.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub struct SignerCoordinator {
7272
/// burn block has arrived since this thread started.
7373
burn_tip_at_start: ConsensusHash,
7474
/// The timeout configuration based on the percentage of rejections
75-
block_rejection_timeout_steps: HashMap<u64, Duration>,
75+
block_rejection_timeout_steps: HashMap<u32, Duration>,
7676
}
7777

7878
impl SignerCoordinator {
@@ -305,21 +305,21 @@ impl SignerCoordinator {
305305
let mut block_rejection_timeout_steps = BTreeMap::<u64, Duration>::new();
306306
for (percentage, duration) in self.block_rejection_timeout_steps.iter() {
307307
let rejections_amount =
308-
((self.total_weight as f64 / 100.0) * *percentage as f64) as u64;
308+
((f64::from(self.total_weight) / 100.0) * f64::from(*percentage)) as u64;
309309
block_rejection_timeout_steps.insert(rejections_amount, *duration);
310310
}
311311

312312
// the amount of current rejections (used to eventually modify the timeout)
313313
let mut rejections: u64 = 0;
314314
// default timeout (the 0 entry must be always present)
315-
let mut rejections_timeout = self
316-
.block_rejection_timeout_steps
317-
.get(&rejections)
318-
.ok_or_else(|| {
319-
NakamotoNodeError::SigningCoordinatorFailure(
320-
"Invalid rejection timeout step function definition".into(),
321-
)
322-
})?;
315+
let mut rejections_timeout =
316+
block_rejection_timeout_steps
317+
.get(&rejections)
318+
.ok_or_else(|| {
319+
NakamotoNodeError::SigningCoordinatorFailure(
320+
"Invalid rejection timeout step function definition".into(),
321+
)
322+
})?;
323323
// this is used for comparing block_status to identify if it has been changed from the previous event
324324
let mut block_status_tracker = BlockStatus::default();
325325

0 commit comments

Comments
 (0)