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

add peer_(dis)connected to custom message handler #3105

Conversation

johncantrell97
Copy link
Contributor

Protocols utilizing the custom message handler might need to know about peer connection and disconnection. At a minimum LSPS5 requires this functionality.

@johncantrell97 johncantrell97 force-pushed the johncantrell97/add-peer-dis/connected-to-cmh branch from 501b6dd to a2a859f Compare June 6, 2024 18:06
@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.83%. Comparing base (2701bc5) to head (602921c).

Files Patch % Lines
lightning/src/ln/peer_handler.rs 80.00% 2 Missing ⚠️

❗ 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.
📢 Have feedback on the report? Share it here.

@johncantrell97 johncantrell97 force-pushed the johncantrell97/add-peer-dis/connected-to-cmh branch 2 times, most recently from 9fe1260 to 432a95d Compare June 6, 2024 19:10
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -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.
Copy link
Collaborator

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".

Copy link
Contributor Author

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);
Copy link
Collaborator

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_disconnecteds to also call this.

Copy link
Contributor Author

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.

@johncantrell97 johncantrell97 force-pushed the johncantrell97/add-peer-dis/connected-to-cmh branch from 432a95d to 1c063e4 Compare June 6, 2024 19:41
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Thanks!

/// Indicates a connection to the peer was lost.
fn peer_disconnected(&self, their_node_id: &PublicKey);

/// Handle a peer reconnecting.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Handle a peer reconnecting.
/// Handle a peer connecting.

Copy link
Contributor

@tnull tnull left a 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.

@@ -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:
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

@tnull tnull Jun 7, 2024

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?

Copy link
Contributor Author

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."

@johncantrell97 johncantrell97 force-pushed the johncantrell97/add-peer-dis/connected-to-cmh branch from 1c063e4 to 602921c Compare June 7, 2024 14:10
@tnull tnull merged commit 9789152 into lightningdevkit:main Jun 7, 2024
16 checks passed
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

Successfully merging this pull request may close these issues.

4 participants