@@ -46,16 +46,23 @@ use bitcoin::hashes::sha256::Hash as Sha256;
4646use bitcoin:: hashes:: sha256:: HashEngine as Sha256Engine ;
4747use bitcoin:: hashes:: { HashEngine , Hash } ;
4848
49- /// Handler for BOLT1-compliant messages.
49+ /// A handler provided to [`PeerManager`] for reading and handling custom messages.
50+ ///
51+ /// [BOLT 1] specifies a custom message type range for use with experimental or application-specific
52+ /// messages. `CustomMessageHandler` allows for user-defined handling of such types. See the
53+ /// [`lightning_custom_message`] crate for tools useful in composing more than one custom handler.
54+ ///
55+ /// [BOLT 1]: https://github.com/lightning/bolts/blob/master/01-messaging.md
56+ /// [`lightning_custom_message`]: https://docs.rs/lightning_custom_message/latest/lightning_custom_message
5057pub trait CustomMessageHandler : wire:: CustomMessageReader {
51- /// Called with the message type that was received and the buffer to be read.
52- /// Can return a `MessageHandlingError` if the message could not be handled.
58+ /// Handles the given message sent from `sender_node_id`, possibly producing messages for
59+ /// [`CustomMessageHandler::get_and_clear_pending_msg`] to return and thus for [`PeerManager`]
60+ /// to send.
5361 fn handle_custom_message ( & self , msg : Self :: CustomMessage , sender_node_id : & PublicKey ) -> Result < ( ) , LightningError > ;
5462
55- /// Gets the list of pending messages which were generated by the custom message
56- /// handler, clearing the list in the process. The first tuple element must
57- /// correspond to the intended recipients node ids. If no connection to one of the
58- /// specified node does not exist, the message is simply not sent to it.
63+ /// Returns the list of pending messages that were generated by the handler, clearing the list
64+ /// in the process. Each message is paired with the node id of the intended recipient. If no
65+ /// connection to the node exists, then the message is simply not sent.
5966 fn get_and_clear_pending_msg ( & self ) -> Vec < ( PublicKey , Self :: CustomMessage ) > ;
6067}
6168
0 commit comments