Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RpcSend on RPC::self_limiter::ready_requests #6634

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

jxs
Copy link
Member

@jxs jxs commented Nov 29, 2024

Issue Addressed

We don't need to store BehaviourAction for ready_requests and therefore avoid having an unreachable! on #6625.
Therefore this PR should be merged before it

@jxs jxs requested a review from ackintosh November 29, 2024 14:49
Copy link
Member

@ackintosh ackintosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @jxs! This is helpful for simplifying #6625, but do we still need unreachable! on #6625 like this?:

                if let RPCSend::Request(request_id, req) = event {
                    //
                } else {
                    unreachable!()
                }

Copy link
Member Author

@jxs jxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @jxs! This is helpful for simplifying #6625, but do we still need unreachable! on #6625 like this?:

                if let RPCSend::Request(request_id, req) = event {
                    //
                } else {
                    unreachable!()
                }

we can just return false on that situation right? (same as before true)

@ackintosh
Copy link
Member

It will look like this if we return false instead of unreachable! on #6625:

    pub fn peer_disconnected(&mut self, peer_id: PeerId) -> Vec<(Id, Protocol)> {
        // ...

        self.ready_requests.retain(|(req_peer_id, event)| {
            if let RPCSend::Request(request_id, req) = event {
                if req_peer_id == &peer_id {
                    failed_requests.push((*request_id, req.protocol()));
                    // Remove the entry
                    false
                } else {
                    // Keep the entry
                    true
                }
            } else {
                // unreachable!()

                // Remove the unexpected RPCSend variant 
                false
            }
        });

We can do that, but I think unreachable! is more appropriate in this situation to clearly indicate that the else clause is unreachable.

@chong-he chong-he added ready-for-review The code is ready for review Networking labels Dec 2, 2024
@jxs jxs added ready-for-merge This PR is ready to merge. trivial and removed ready-for-review The code is ready for review ready-for-merge This PR is ready to merge. labels Feb 18, 2025
mergify bot added a commit that referenced this pull request Feb 19, 2025
Copy link

mergify bot commented Feb 19, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

Copy link

mergify bot commented Feb 19, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

@mergify mergify bot merged commit 193061f into sigp:unstable Feb 19, 2025
31 checks passed
pawanjay176 pushed a commit to pawanjay176/lighthouse that referenced this pull request Feb 21, 2025
We don't need to store `BehaviourAction` for `ready_requests` and therefore avoid having an `unreachable!` on sigp#6625.
Therefore this PR should be merged before it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants