Skip to content

Commit

Permalink
use u32 for rejections counter
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeioris committed Feb 3, 2025
1 parent 0c86012 commit 400c806
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions testnet/stacks-node/src/nakamoto_node/signer_coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct SignerCoordinator {
/// burn block has arrived since this thread started.
burn_tip_at_start: ConsensusHash,
/// The timeout configuration based on the percentage of rejections
block_rejection_timeout_steps: BTreeMap<u64, Duration>,
block_rejection_timeout_steps: BTreeMap<u32, Duration>,
}

impl SignerCoordinator {
Expand Down Expand Up @@ -107,10 +107,10 @@ impl SignerCoordinator {
let miners_session = StackerDBSession::new(&rpc_socket.to_string(), miners_contract_id);

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

Expand Down Expand Up @@ -308,7 +308,7 @@ impl SignerCoordinator {
counters: &Counters,
) -> Result<Vec<MessageSignature>, NakamotoNodeError> {
// the amount of current rejections (used to eventually modify the timeout)
let mut rejections: u64 = 0;
let mut rejections: u32 = 0;
// default timeout (the 0 entry must be always present)
let mut rejections_timeout = self
.block_rejection_timeout_steps
Expand All @@ -334,7 +334,7 @@ impl SignerCoordinator {
return false;
}
// number or rejections changed?
if u64::from(status.total_reject_weight) != rejections {
if status.total_reject_weight != rejections {
return false;
}
// enough signatures?
Expand Down Expand Up @@ -388,8 +388,8 @@ impl SignerCoordinator {
}
};

if rejections != u64::from(block_status.total_reject_weight) {
rejections = u64::from(block_status.total_reject_weight);
if rejections != block_status.total_reject_weight {
rejections = block_status.total_reject_weight;
let (rejections_step, new_rejections_timeout) = self
.block_rejection_timeout_steps
.range((Included(0), Included(rejections)))
Expand All @@ -406,7 +406,7 @@ impl SignerCoordinator {
"rejections_step" => rejections_step,
"rejections_threshold" => self.total_weight.saturating_sub(self.weight_threshold));

counters.set_miner_current_rejections_timeout(rejections_timeout.as_secs());
counters.set_miner_current_rejections_timeout_secs(rejections_timeout.as_secs());
counters.set_miner_current_rejections(rejections);
}

Expand Down
6 changes: 3 additions & 3 deletions testnet/stacks-node/src/run_loop/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ impl Counters {
Counters::set(&self.microblocks_processed, value)
}

pub fn set_miner_current_rejections_timeout(&self, value: u64) {
pub fn set_miner_current_rejections_timeout_secs(&self, value: u64) {
Counters::set(&self.naka_miner_current_rejections_timeout_secs, value)
}

pub fn set_miner_current_rejections(&self, value: u64) {
Counters::set(&self.naka_miner_current_rejections, value)
pub fn set_miner_current_rejections(&self, value: u32) {
Counters::set(&self.naka_miner_current_rejections, u64::from(value))
}
}

Expand Down

0 comments on commit 400c806

Please sign in to comment.