Skip to content

Commit 7cfbfdd

Browse files
committed
refactored block_rejection_timeout_steps percentage setup
1 parent adaabe6 commit 7cfbfdd

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,21 @@ impl SignerCoordinator {
279279
}
280280
}
281281

282+
// build a BTreeMap of the various timeout steps
283+
let mut block_rejection_timeout_steps = BTreeMap::<u64, Duration>::new();
284+
for (percentage, duration) in self.block_rejection_timeout_steps.iter() {
285+
let rejections_amount =
286+
((f64::from(self.total_weight) / 100.0) * f64::from(*percentage)) as u64;
287+
block_rejection_timeout_steps.insert(rejections_amount, *duration);
288+
}
289+
282290
self.get_block_status(
283291
&block.header.signer_signature_hash(),
284292
&block.block_id(),
285293
chain_state,
286294
sortdb,
287295
counters,
296+
&block_rejection_timeout_steps,
288297
)
289298
}
290299

@@ -300,15 +309,8 @@ impl SignerCoordinator {
300309
chain_state: &mut StacksChainState,
301310
sortdb: &SortitionDB,
302311
counters: &Counters,
312+
block_rejection_timeout_steps: &BTreeMap<u64, Duration>,
303313
) -> Result<Vec<MessageSignature>, NakamotoNodeError> {
304-
// build a BTreeMap of the various timeout steps
305-
let mut block_rejection_timeout_steps = BTreeMap::<u64, Duration>::new();
306-
for (percentage, duration) in self.block_rejection_timeout_steps.iter() {
307-
let rejections_amount =
308-
((f64::from(self.total_weight) / 100.0) * f64::from(*percentage)) as u64;
309-
block_rejection_timeout_steps.insert(rejections_amount, *duration);
310-
}
311-
312314
// the amount of current rejections (used to eventually modify the timeout)
313315
let mut rejections: u64 = 0;
314316
// default timeout (the 0 entry must be always present)

0 commit comments

Comments
 (0)