-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(relay): emit event when all client connections are dropped #5869
base: master
Are you sure you want to change the base?
feat(relay): emit event when all client connections are dropped #5869
Conversation
61d5841
to
7f11002
Compare
7f11002
to
1664632
Compare
peer.get_mut().remove(&connection_id); | ||
if peer.get().is_empty() { | ||
peer.remove(); | ||
self.queued_actions | ||
.push_back(ToSwarm::GenerateEvent(Event::ReservationClosed { | ||
src_peer_id: peer_id, | ||
})); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
peer.get_mut().remove(&connection_id); | |
if peer.get().is_empty() { | |
peer.remove(); | |
self.queued_actions | |
.push_back(ToSwarm::GenerateEvent(Event::ReservationClosed { | |
src_peer_id: peer_id, | |
})); | |
} | |
if peer.get_mut().remove(&connection_id) { | |
self.queued_actions | |
.push_back(ToSwarm::GenerateEvent(Event::ReservationClosed { | |
src_peer_id: peer_id, | |
})); | |
} | |
if peer.get().is_empty() { | |
peer.remove(); | |
} |
We may have multiple connections to a peer, so we should emit the event when a connection closes for which we have an active reservation.
Maybe it also makes sense to include the connection id in the event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Additionally, we should also include the connection id of which we had the reservation since there may be multiple reservation to a peer with different connections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it complete, the other events should also have connection IDs: ReservationReqAccepted
, ReservationReqDenied
and ReservationTimedOut
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we keep the ReservationClosed
variant without the connection-id in this PR, and do a separate one that adds it for all of the mentioned variants (and discuss there if we want to in the first place)? That way it's consistent.
Description
When a relay server has no more connection with a reserved client, it would remove the reservation and the drop the circuits without any information passed to the server. It will be useful to for a server to track all its reservations and to know when they're removed (without keeping track of the connections themselves).
This PR aims to notify the server when a reservation closes, with the emission of the following event
Change checklist