Skip to content

Commit 9bb5138

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 7d56270 commit 9bb5138

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
@@ -1933,9 +1933,11 @@ pub trait BaseMessageHandler {
19331933

19341934
/// Handle a peer (re)connecting.
19351935
///
1936-
/// May return an `Err(())` if the features the peer supports are not sufficient to communicate
1937-
/// with us. Implementors should be somewhat conservative about doing so, however, as other
1938-
/// message handlers may still wish to communicate with this peer.
1936+
/// May return an `Err(())` to indicate that we should immediately disconnect from the peer
1937+
/// (e.g. because the features they support are not sufficient to communicate with us).
1938+
///
1939+
/// Note, of course, that other message handlers may wish to communicate with the peer, which
1940+
/// disconnecting them will prevent.
19391941
///
19401942
/// [`Self::peer_disconnected`] will not be called if `Err(())` is returned.
19411943
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)