Skip to content

Consider Updating the PeerManager API to allow send-warning-before-disconnect #1284

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

Open
TheBlueMatt opened this issue Jan 26, 2022 · 2 comments

Comments

@TheBlueMatt
Copy link
Collaborator

See note added in #1283. The API we have is not at all amenable to sending a message before disconnecting, and its unclear how exactly to enable it. We don't really want to call the users' write method from read_event (we faught hard to remove it). We could consider making the disconnection a "message" which we put in the message queue, allowing it to be handled via the normal message sending pipelines. Ideally of course we'd stop processing inbound messages from the peer after we decide they are useless, however, which would require some additional state tracking.

@wpaulino
Copy link
Contributor

Is this about allowing the send from the rest of LDK (which we already have via MessageSendEvent::HandleError::ErrorAction::DisconnectPeerWithWarning) or externally? I assume the latter.

@TheBlueMatt
Copy link
Collaborator Author

This is about the comments in do_read_event where we get a warning or error message to send to peers, but then immediately want to disconnect. eg

                                            // We may have an `ErrorMessage` to send to the peer,
                                            // but writing to the socket while reading can lead to
                                            // re-entrant code and possibly unexpected behavior. The
                                            // message send is optimistic anyway, and in this case
                                            // we immediately disconnect the peer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants