Skip to content

Commit 400c806

Browse files
committed
use u32 for rejections counter
1 parent 0c86012 commit 400c806

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct SignerCoordinator {
7070
/// burn block has arrived since this thread started.
7171
burn_tip_at_start: ConsensusHash,
7272
/// The timeout configuration based on the percentage of rejections
73-
block_rejection_timeout_steps: BTreeMap<u64, Duration>,
73+
block_rejection_timeout_steps: BTreeMap<u32, Duration>,
7474
}
7575

7676
impl SignerCoordinator {
@@ -107,10 +107,10 @@ impl SignerCoordinator {
107107
let miners_session = StackerDBSession::new(&rpc_socket.to_string(), miners_contract_id);
108108

109109
// build a BTreeMap of the various timeout steps
110-
let mut block_rejection_timeout_steps = BTreeMap::<u64, Duration>::new();
110+
let mut block_rejection_timeout_steps = BTreeMap::<u32, Duration>::new();
111111
for (percentage, duration) in config.miner.block_rejection_timeout_steps.iter() {
112112
let rejections_amount =
113-
((f64::from(listener.total_weight) / 100.0) * f64::from(*percentage)) as u64;
113+
((f64::from(listener.total_weight) / 100.0) * f64::from(*percentage)) as u32;
114114
block_rejection_timeout_steps.insert(rejections_amount, *duration);
115115
}
116116

@@ -308,7 +308,7 @@ impl SignerCoordinator {
308308
counters: &Counters,
309309
) -> Result<Vec<MessageSignature>, NakamotoNodeError> {
310310
// the amount of current rejections (used to eventually modify the timeout)
311-
let mut rejections: u64 = 0;
311+
let mut rejections: u32 = 0;
312312
// default timeout (the 0 entry must be always present)
313313
let mut rejections_timeout = self
314314
.block_rejection_timeout_steps
@@ -334,7 +334,7 @@ impl SignerCoordinator {
334334
return false;
335335
}
336336
// number or rejections changed?
337-
if u64::from(status.total_reject_weight) != rejections {
337+
if status.total_reject_weight != rejections {
338338
return false;
339339
}
340340
// enough signatures?
@@ -388,8 +388,8 @@ impl SignerCoordinator {
388388
}
389389
};
390390

391-
if rejections != u64::from(block_status.total_reject_weight) {
392-
rejections = u64::from(block_status.total_reject_weight);
391+
if rejections != block_status.total_reject_weight {
392+
rejections = block_status.total_reject_weight;
393393
let (rejections_step, new_rejections_timeout) = self
394394
.block_rejection_timeout_steps
395395
.range((Included(0), Included(rejections)))
@@ -406,7 +406,7 @@ impl SignerCoordinator {
406406
"rejections_step" => rejections_step,
407407
"rejections_threshold" => self.total_weight.saturating_sub(self.weight_threshold));
408408

409-
counters.set_miner_current_rejections_timeout(rejections_timeout.as_secs());
409+
counters.set_miner_current_rejections_timeout_secs(rejections_timeout.as_secs());
410410
counters.set_miner_current_rejections(rejections);
411411
}
412412

testnet/stacks-node/src/run_loop/neon.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ impl Counters {
218218
Counters::set(&self.microblocks_processed, value)
219219
}
220220

221-
pub fn set_miner_current_rejections_timeout(&self, value: u64) {
221+
pub fn set_miner_current_rejections_timeout_secs(&self, value: u64) {
222222
Counters::set(&self.naka_miner_current_rejections_timeout_secs, value)
223223
}
224224

225-
pub fn set_miner_current_rejections(&self, value: u64) {
226-
Counters::set(&self.naka_miner_current_rejections, value)
225+
pub fn set_miner_current_rejections(&self, value: u32) {
226+
Counters::set(&self.naka_miner_current_rejections, u64::from(value))
227227
}
228228
}
229229

0 commit comments

Comments
 (0)