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