File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
lightning/src/onion_message Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -943,6 +943,27 @@ where
943
943
}
944
944
}
945
945
946
+ /// Forwards an [`OnionMessage`] to `peer_node_id`. Useful if we initialized
947
+ /// the [`OnionMessenger`] with [`Self::new_with_offline_peer_interception`]
948
+ /// and want to forward a previously intercepted onion message to a peer that
949
+ /// has just come online.
950
+ pub fn forward_onion_message (
951
+ & self , message : OnionMessage , peer_node_id : & PublicKey
952
+ ) -> Result < ( ) , SendError > {
953
+ let mut message_recipients = self . message_recipients . lock ( ) . unwrap ( ) ;
954
+ if outbound_buffer_full ( & peer_node_id, & message_recipients) {
955
+ return Err ( SendError :: BufferFull ) ;
956
+ }
957
+
958
+ match message_recipients. entry ( * peer_node_id) {
959
+ hash_map:: Entry :: Occupied ( mut e) if e. get ( ) . is_connected ( ) => {
960
+ e. get_mut ( ) . enqueue_message ( message) ;
961
+ Ok ( ( ) )
962
+ } ,
963
+ _ => Err ( SendError :: InvalidFirstHop ( * peer_node_id) )
964
+ }
965
+ }
966
+
946
967
#[ cfg( any( test, feature = "_test_utils" ) ) ]
947
968
pub fn send_onion_message_using_path < T : OnionMessageContents > (
948
969
& self , path : OnionMessagePath , contents : T , reply_path : Option < BlindedPath >
You can’t perform that action at this time.
0 commit comments