Skip to content

Commit daefd33

Browse files
committed
Re-write CustomMessageHandler documentation
Documentation for CustomMessageHandler wasn't clear how it is related to PeerManager and contained some grammatical and factual errors. Re-write the docs and link to the lightning_custom_message crate.
1 parent ef93299 commit daefd33

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lightning/src/ln/peer_handler.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,23 @@ use bitcoin::hashes::sha256d::Hash as Sha256dHash;
4747
use bitcoin::hashes::sha256::HashEngine as Sha256Engine;
4848
use bitcoin::hashes::{HashEngine, Hash};
4949

50-
/// Handler for BOLT1-compliant messages.
50+
/// A handler provided to [`PeerManager`] for reading and handling custom messages.
51+
///
52+
/// [BOLT 1] specifies a custom message type range for use with experimental or application-specific
53+
/// messages. `CustomMessageHandler` allows for user-defined handling of such types. See the
54+
/// [`lightning_custom_message`] crate for tools useful in composing more than one custom handler.
55+
///
56+
/// [BOLT 1]: https://github.com/lightning/bolts/blob/master/01-messaging.md
57+
/// [`lightning_custom_message`]: https://docs.rs/lightning_custom_message/latest/lightning_custom_message
5158
pub trait CustomMessageHandler: wire::CustomMessageReader {
52-
/// Called with the message type that was received and the buffer to be read.
53-
/// Can return a `MessageHandlingError` if the message could not be handled.
59+
/// Handles the given message sent from `sender_node_id`, possibly producing messages for
60+
/// [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`]
61+
/// to send.
5462
fn handle_custom_message(&self, msg: Self::CustomMessage, sender_node_id: &PublicKey) -> Result<(), LightningError>;
5563

56-
/// Gets the list of pending messages which were generated by the custom message
57-
/// handler, clearing the list in the process. The first tuple element must
58-
/// correspond to the intended recipients node ids. If no connection to one of the
59-
/// specified node does not exist, the message is simply not sent to it.
64+
/// Returns the list of pending messages that were generated by the handler, clearing the list
65+
/// in the process. Each message is paired with the node id of the intended recipient. If a
66+
/// connection to any given node does not exist, then the message is simply not sent.
6067
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>;
6168
}
6269

0 commit comments

Comments
 (0)