-
Notifications
You must be signed in to change notification settings - Fork 385
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
add peer_(dis)connected to custom message handler #3105
add peer_(dis)connected to custom message handler #3105
Conversation
501b6dd
to
a2a859f
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #3105 +/- ##
==========================================
- Coverage 89.88% 89.83% -0.06%
==========================================
Files 119 119
Lines 97551 97561 +10
Branches 97551 97561 +10
==========================================
- Hits 87681 87640 -41
- Misses 7304 7343 +39
- Partials 2566 2578 +12 ☔ View full report in Codecov by Sentry. |
9fe1260
to
432a95d
Compare
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.
Thanks!
lightning/src/ln/peer_handler.rs
Outdated
@@ -79,6 +79,17 @@ pub trait CustomMessageHandler: wire::CustomMessageReader { | |||
/// connection to the node exists, then the message is simply not sent. | |||
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>; | |||
|
|||
// Connection loss/reestablish: | |||
/// Indicates a connection to the peer failed/an existing connection was lost. |
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.
IIRC this only fires if we previously called peer_connected
, so it is not called if a connection "fails".
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.
Oh ok, might want to change it on ChannelMessageHandler too then?
@@ -79,6 +79,17 @@ pub trait CustomMessageHandler: wire::CustomMessageReader { | |||
/// connection to the node exists, then the message is simply not sent. | |||
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>; | |||
|
|||
// Connection loss/reestablish: | |||
/// Indicates a connection to the peer failed/an existing connection was lost. | |||
fn peer_disconnected(&self, their_node_id: &PublicKey); |
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.
This is currently not called in PeerManager
, we should update the places we currently call the other peer_disconnected
s to also call this.
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.
Right, whoops. I think I fixed this.
432a95d
to
1c063e4
Compare
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.
Thanks!
lightning/src/ln/peer_handler.rs
Outdated
/// Indicates a connection to the peer was lost. | ||
fn peer_disconnected(&self, their_node_id: &PublicKey); | ||
|
||
/// Handle a peer reconnecting. |
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.
/// Handle a peer reconnecting. | |
/// Handle a peer connecting. |
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.
Two nits, otherwise LGTM mod the open comments.
lightning/src/ln/peer_handler.rs
Outdated
@@ -79,6 +79,17 @@ pub trait CustomMessageHandler: wire::CustomMessageReader { | |||
/// connection to the node exists, then the message is simply not sent. | |||
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>; | |||
|
|||
// Connection loss/reestablish: |
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.
nit: Can we remove this non-doc comment? Seems superfluous.
lightning/src/ln/peer_handler.rs
Outdated
@@ -79,6 +79,17 @@ pub trait CustomMessageHandler: wire::CustomMessageReader { | |||
/// connection to the node exists, then the message is simply not sent. | |||
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>; | |||
|
|||
// Connection loss/reestablish: | |||
/// Indicates a connection to the peer was lost. |
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.
nit: "a connection to the peer was lost." sounds like it timed out, but of course this could also be a regular disconnect?
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.
Hm, I guess lost sort of implies an unintentional disconnection but it's still pretty generic. How about just keeping it simple and saying "Indicates a peer disconnected."
1c063e4
to
602921c
Compare
Protocols utilizing the custom message handler might need to know about peer connection and disconnection. At a minimum LSPS5 requires this functionality.