Skip to content

Commit 1b40d56

Browse files
Fill in top-level docs for onion message offline peer interception.
1 parent 5e2b3ba commit 1b40d56

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lightning/src/onion_message/messenger.rs

+20
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,27 @@ where
805805
)
806806
}
807807

808+
/// Similar to [`Self::new`], but rather than dropping onion messages that are
809+
/// intended to be forwarded to offline peers, we will intercept them for
810+
/// later forwarding.
808811
///
812+
/// Interception flow:
813+
/// 1. If an onion message for an offline peer is received, `OnionMessenger` will
814+
/// generate an [`Event::OnionMessageForOfflinePeer`]. Event handlers can
815+
/// then choose to persist this onion message for later forwarding, or drop
816+
/// it.
817+
/// 2. When the offline peer later comes back online, `OnionMessenger` will
818+
/// generate an [`Event::OnionMessagePeerConnected`]. Event handlers will
819+
/// then fetch all previously intercepted onion messages for this peer.
820+
/// 3. Once the stored onion messages are fetched, they can finally be
821+
/// forwarded to the now-online peer via [`Self::forward_onion_message`].
822+
///
823+
/// # Note
824+
///
825+
/// LDK will not rate limit how many [`Event::OnionMessageForOfflinePeer`]s
826+
/// are generated, so it is the caller's responsibility to limit how many
827+
/// onion messages are persisted and only persist onion messages for relevant
828+
/// peers.
809829
pub fn new_with_offline_peer_interception(
810830
entropy_source: ES, node_signer: NS, logger: L, node_id_lookup: NL,
811831
message_router: MR, offers_handler: OMH, custom_handler: CMH

0 commit comments

Comments
 (0)