@@ -10870,6 +10870,23 @@ where
10870
10870
now
10871
10871
}
10872
10872
10873
+ fn get_peers_for_blinded_path(&self) -> Vec<MessageForwardNode> {
10874
+ self.per_peer_state.read().unwrap()
10875
+ .iter()
10876
+ .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10877
+ .filter(|(_, peer)| peer.is_connected)
10878
+ .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10879
+ .map(|(node_id, peer)| MessageForwardNode {
10880
+ node_id: *node_id,
10881
+ short_channel_id: peer.channel_by_id
10882
+ .iter()
10883
+ .filter(|(_, channel)| channel.context().is_usable())
10884
+ .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10885
+ .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10886
+ })
10887
+ .collect::<Vec<_>>()
10888
+ }
10889
+
10873
10890
/// Creates a collection of blinded paths by delegating to
10874
10891
/// [`MessageRouter::create_blinded_paths`].
10875
10892
///
@@ -10878,16 +10895,7 @@ where
10878
10895
let recipient = self.get_our_node_id();
10879
10896
let secp_ctx = &self.secp_ctx;
10880
10897
10881
- let peers = self.per_peer_state.read().unwrap()
10882
- .iter()
10883
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10884
- .filter(|(_, peer)| peer.is_connected)
10885
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10886
- .map(|(node_id, _)| MessageForwardNode {
10887
- node_id: *node_id,
10888
- short_channel_id: None
10889
- })
10890
- .collect::<Vec<_>>();
10898
+ let peers = self.get_peers_for_blinded_path();
10891
10899
10892
10900
self.message_router
10893
10901
.create_blinded_paths(recipient, context, peers, secp_ctx)
@@ -10902,20 +10910,7 @@ where
10902
10910
let recipient = self.get_our_node_id();
10903
10911
let secp_ctx = &self.secp_ctx;
10904
10912
10905
- let peers = self.per_peer_state.read().unwrap()
10906
- .iter()
10907
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10908
- .filter(|(_, peer)| peer.is_connected)
10909
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10910
- .map(|(node_id, peer)| MessageForwardNode {
10911
- node_id: *node_id,
10912
- short_channel_id: peer.channel_by_id
10913
- .iter()
10914
- .filter(|(_, channel)| channel.context().is_usable())
10915
- .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10916
- .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10917
- })
10918
- .collect::<Vec<_>>();
10913
+ let peers = self.get_peers_for_blinded_path();
10919
10914
10920
10915
self.message_router
10921
10916
.create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
0 commit comments