Skip to content

Commit fd64cb0

Browse files
committed
Update peer_connected documentation to better describe Err(())
Our `peer_connected` methods can return `Err(())` to cause the peer to be immediately disconnected. The documentation for them, however, only described the specific case of using this to enforce minimal set of per feature bits. Instead, here, we tweak the documentation to describe the high-level utility, and only mention enforcing peer feature bits as an example use-case.
1 parent 426239b commit fd64cb0

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lightning/src/ln/msgs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,9 +1873,11 @@ pub trait BaseMessageHandler {
18731873

18741874
/// Handle a peer (re)connecting.
18751875
///
1876-
/// May return an `Err(())` if the features the peer supports are not sufficient to communicate
1877-
/// with us. Implementors should be somewhat conservative about doing so, however, as other
1878-
/// message handlers may still wish to communicate with this peer.
1876+
/// May return an `Err(())` to indicate that we should immediately disconnect from the peer
1877+
/// (e.g. because the features they support are not sufficient to communicate with us).
1878+
///
1879+
/// Note, of course, that other message handlers may wish to communicate with the peer, which
1880+
/// disconnecting them will prevent.
18791881
///
18801882
/// [`Self::peer_disconnected`] will not be called if `Err(())` is returned.
18811883
fn peer_connected(&self, their_node_id: PublicKey, msg: &Init, inbound: bool)

lightning/src/ln/peer_handler.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ pub trait CustomMessageHandler: wire::CustomMessageReader {
9898

9999
/// Handle a peer connecting.
100100
///
101-
/// May return an `Err(())` if the features the peer supports are not sufficient to communicate
102-
/// with us. Implementors should be somewhat conservative about doing so, however, as other
103-
/// message handlers may still wish to communicate with this peer.
101+
/// May return an `Err(())` to indicate that we should immediately disconnect from the peer
102+
/// (e.g. because the features they support are not sufficient to communicate with us).
103+
///
104+
/// Note, of course, that other message handlers may wish to communicate with the peer, which
105+
/// disconnecting them will prevent.
104106
///
105107
/// [`Self::peer_disconnected`] will not be called if `Err(())` is returned.
106108
fn peer_connected(&self, their_node_id: PublicKey, msg: &Init, inbound: bool)

0 commit comments

Comments
 (0)