refactor: split get_requests_to_attempt in queue.rs#3286
Conversation
get_requests_to_attempt in queue.rs
|
Pull request overview Pure refactor of crates/node/src/requests/queue.rs. The previously large get_requests_to_attempt body is split into focused helpers on QueuedRequest (update_next_check_due, has_active_attempt, is_older_than, process) and on ComputationProgress (update_computation_progress). Control flow is expressed via new RequestStatusResult and RemovalReason enums, with metric_label() centralizing the MPC_CLUSTER_FAILED_SIGNATURES_COUNT label mapping. Outward behavior is preserved. Changes
Reviewed changes Findings Verified behavior matches the original on every branch:
Non-blocking nits
Approved. |
There was a problem hiding this comment.
Pull request overview
This PR refactors PendingRequests::get_requests_to_attempt in crates/node/src/requests/queue.rs by extracting per-request decision logic into QueuedRequest::process and introducing small helper enums, improving readability and making individual decision paths more explicit (as part of the broader work in #3070).
Changes:
- Extracted request evaluation logic into
QueuedRequest::processand small helper methods (update_next_check_due,has_active_attempt,is_older_than). - Introduced
RemovalReason/RequestStatusResultto centralize removal/skip/attempt outcomes and metric label selection. - Simplified cutoff-block computation and removed an unused
std::ops::Addimport.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// If [`Self::attempts`] is less than [`MAX_ATTEMPTS_PER_REQUEST_AS_LEADER`], then increments | ||
| /// [`Self::attempts`] by one and returns [`ComputationProgressStatus::NewAttempt`]. | ||
| /// Otherwise returns [`ComputationProgressStatus::MaxAttemptsExceeded`] or | ||
| /// [`ComputationProgressStatus::Pending`]. |
| RequestStatusResult::Remove(RemovalReason::MaxAttemptsExceeded) | ||
| } | ||
| ComputationProgressStatus::Pending => { | ||
| RequestStatusResult::Wait("pending computation") |
Part of #3070