Skip to content

Commit daf21f6

Browse files
committed
Remove signers older than the current reward cycle if they have no more blocks to process
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent b108d09 commit daf21f6

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

stacks-signer/src/runloop.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -423,23 +423,15 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
423423
let mut to_delete = Vec::new();
424424
for (idx, signer) in &mut self.stacks_signers {
425425
let reward_cycle = signer.reward_cycle();
426-
let next_reward_cycle = reward_cycle.wrapping_add(1);
427-
let stale = match next_reward_cycle.cmp(&current_reward_cycle) {
428-
std::cmp::Ordering::Less => true, // We are more than one reward cycle behind, so we are stale
429-
std::cmp::Ordering::Equal => {
430-
// We are the next reward cycle, so check if we were registered and have any pending blocks to process
431-
match signer {
432-
ConfiguredSigner::RegisteredSigner(signer) => {
433-
!signer.has_unprocessed_blocks()
434-
}
435-
_ => true,
436-
}
426+
if current_reward_cycle >= reward_cycle {
427+
// We are either the current or a future reward cycle, so we are not stale.
428+
continue;
429+
}
430+
if let ConfiguredSigner::RegisteredSigner(signer) = signer {
431+
if !signer.has_unprocessed_blocks() {
432+
debug!("{signer}: Signer's tenure has completed.");
433+
to_delete.push(*idx);
437434
}
438-
std::cmp::Ordering::Greater => false, // We are the current reward cycle, so we are not stale
439-
};
440-
if stale {
441-
debug!("{signer}: Signer's tenure has completed.");
442-
to_delete.push(*idx);
443435
}
444436
}
445437
for idx in to_delete {

0 commit comments

Comments
 (0)