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

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Networking ready-for-review The code is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants