@@ -10891,6 +10891,23 @@ where
10891
10891
now
10892
10892
}
10893
10893
10894
+ fn get_peers_for_blinded_path(&self) -> Vec<MessageForwardNode> {
10895
+ self.per_peer_state.read().unwrap()
10896
+ .iter()
10897
+ .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10898
+ .filter(|(_, peer)| peer.is_connected)
10899
+ .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10900
+ .map(|(node_id, peer)| MessageForwardNode {
10901
+ node_id: *node_id,
10902
+ short_channel_id: peer.channel_by_id
10903
+ .iter()
10904
+ .filter(|(_, channel)| channel.context().is_usable())
10905
+ .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10906
+ .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10907
+ })
10908
+ .collect::<Vec<_>>()
10909
+ }
10910
+
10894
10911
/// Creates a collection of blinded paths by delegating to
10895
10912
/// [`MessageRouter::create_blinded_paths`].
10896
10913
///
@@ -10899,13 +10916,10 @@ where
10899
10916
let recipient = self.get_our_node_id();
10900
10917
let secp_ctx = &self.secp_ctx;
10901
10918
10902
- let peers = self.per_peer_state.read().unwrap()
10903
- .iter()
10904
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10905
- .filter(|(_, peer)| peer.is_connected)
10906
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10907
- .map(|(node_id, _)| *node_id)
10908
- .collect::<Vec<_>>();
10919
+ let peers = self.get_peers_for_blinded_path()
10920
+ .into_iter()
10921
+ .map(|node| node.node_id)
10922
+ .collect();
10909
10923
10910
10924
self.message_router
10911
10925
.create_blinded_paths(recipient, context, peers, secp_ctx)
@@ -10920,20 +10934,7 @@ where
10920
10934
let recipient = self.get_our_node_id();
10921
10935
let secp_ctx = &self.secp_ctx;
10922
10936
10923
- let peers = self.per_peer_state.read().unwrap()
10924
- .iter()
10925
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10926
- .filter(|(_, peer)| peer.is_connected)
10927
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10928
- .map(|(node_id, peer)| MessageForwardNode {
10929
- node_id: *node_id,
10930
- short_channel_id: peer.channel_by_id
10931
- .iter()
10932
- .filter(|(_, channel)| channel.context().is_usable())
10933
- .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10934
- .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10935
- })
10936
- .collect::<Vec<_>>();
10937
+ let peers = self.get_peers_for_blinded_path();
10937
10938
10938
10939
self.message_router
10939
10940
.create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
0 commit comments