Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Drop timers for new requests of active participations #6974

Merged
merged 12 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions node/core/dispute-coordinator/src/participation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ impl Participation {
&mut self,
ctx: &mut Context,
priority: ParticipationPriority,
req: ParticipationRequest,
mut req: ParticipationRequest,
) -> Result<()> {
// Participation already running - we can ignore that request:
// Participation already running - we can ignore that request, discarding its timer:
if self.running_participations.contains(req.candidate_hash()) {
req.discard_timer();
return Ok(())
}
// Available capacity - participate right away (if we already have a recent block):
Expand Down
19 changes: 8 additions & 11 deletions node/core/dispute-coordinator/src/participation/queues/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ impl ParticipationRequest {
pub fn session(&self) -> SessionIndex {
self.session
}
pub fn discard_timer(&mut self) {
if let Some(timer) = self.request_timer.take() {
timer.stop_and_discard();
}
}
pub fn into_candidate_info(self) -> (CandidateHash, CandidateReceipt) {
let Self { candidate_hash, candidate_receipt, .. } = self;
(candidate_hash, candidate_receipt)
Expand Down Expand Up @@ -246,17 +251,12 @@ impl Queues {
// Remove any best effort entry, using it to replace our new
// request.
if let Some(older_request) = self.best_effort.remove(&comparator) {
if let Some(timer) = req.request_timer {
timer.stop_and_discard();
}
req.discard_timer();
req = older_request;
}
// Keeping old request if any.
match self.priority.entry(comparator) {
Entry::Occupied(_) =>
if let Some(timer) = req.request_timer {
timer.stop_and_discard();
},
Entry::Occupied(_) => req.discard_timer(),
Entry::Vacant(vac) => {
vac.insert(req);
},
Expand All @@ -274,10 +274,7 @@ impl Queues {
}
// Keeping old request if any.
match self.best_effort.entry(comparator) {
Entry::Occupied(_) =>
if let Some(timer) = req.request_timer {
timer.stop_and_discard();
},
Entry::Occupied(_) => req.discard_timer(),
Entry::Vacant(vac) => {
vac.insert(req);
},
Expand Down