@@ -10763,6 +10763,23 @@ where
10763
10763
now
10764
10764
}
10765
10765
10766
+ fn get_peers_for_blinded_path(&self) -> Vec<MessageForwardNode> {
10767
+ self.per_peer_state.read().unwrap()
10768
+ .iter()
10769
+ .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10770
+ .filter(|(_, peer)| peer.is_connected)
10771
+ .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10772
+ .map(|(node_id, peer)| MessageForwardNode {
10773
+ node_id: *node_id,
10774
+ short_channel_id: peer.channel_by_id
10775
+ .iter()
10776
+ .filter(|(_, channel)| channel.context().is_usable())
10777
+ .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10778
+ .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10779
+ })
10780
+ .collect::<Vec<_>>()
10781
+ }
10782
+
10766
10783
/// Creates a collection of blinded paths by delegating to
10767
10784
/// [`MessageRouter::create_blinded_paths`].
10768
10785
///
@@ -10771,13 +10788,10 @@ where
10771
10788
let recipient = self.get_our_node_id();
10772
10789
let secp_ctx = &self.secp_ctx;
10773
10790
10774
- let peers = self.per_peer_state.read().unwrap()
10775
- .iter()
10776
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10777
- .filter(|(_, peer)| peer.is_connected)
10778
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10779
- .map(|(node_id, _)| *node_id)
10780
- .collect::<Vec<_>>();
10791
+ let peers = self.get_peers_for_blinded_path()
10792
+ .into_iter()
10793
+ .map(|node| node.node_id)
10794
+ .collect();
10781
10795
10782
10796
self.message_router
10783
10797
.create_blinded_paths(recipient, context, peers, secp_ctx)
@@ -10792,20 +10806,7 @@ where
10792
10806
let recipient = self.get_our_node_id();
10793
10807
let secp_ctx = &self.secp_ctx;
10794
10808
10795
- let peers = self.per_peer_state.read().unwrap()
10796
- .iter()
10797
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10798
- .filter(|(_, peer)| peer.is_connected)
10799
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10800
- .map(|(node_id, peer)| MessageForwardNode {
10801
- node_id: *node_id,
10802
- short_channel_id: peer.channel_by_id
10803
- .iter()
10804
- .filter(|(_, channel)| channel.context().is_usable())
10805
- .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10806
- .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10807
- })
10808
- .collect::<Vec<_>>();
10809
+ let peers = self.get_peers_for_blinded_path();
10809
10810
10810
10811
self.message_router
10811
10812
.create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
0 commit comments