@@ -10588,6 +10588,23 @@ where
10588
10588
now
10589
10589
}
10590
10590
10591
+ fn get_peers_for_blinded_path(&self) -> Vec<MessageForwardNode> {
10592
+ self.per_peer_state.read().unwrap()
10593
+ .iter()
10594
+ .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10595
+ .filter(|(_, peer)| peer.is_connected)
10596
+ .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10597
+ .map(|(node_id, peer)| MessageForwardNode {
10598
+ node_id: *node_id,
10599
+ short_channel_id: peer.channel_by_id
10600
+ .iter()
10601
+ .filter(|(_, channel)| channel.context().is_usable())
10602
+ .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10603
+ .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10604
+ })
10605
+ .collect::<Vec<_>>()
10606
+ }
10607
+
10591
10608
/// Creates a collection of blinded paths by delegating to
10592
10609
/// [`MessageRouter::create_blinded_paths`].
10593
10610
///
@@ -10596,13 +10613,10 @@ where
10596
10613
let recipient = self.get_our_node_id();
10597
10614
let secp_ctx = &self.secp_ctx;
10598
10615
10599
- let peers = self.per_peer_state.read().unwrap()
10600
- .iter()
10601
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10602
- .filter(|(_, peer)| peer.is_connected)
10603
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10604
- .map(|(node_id, _)| *node_id)
10605
- .collect::<Vec<_>>();
10616
+ let peers = self.get_peers_for_blinded_path()
10617
+ .into_iter()
10618
+ .map(|node| node.node_id)
10619
+ .collect();
10606
10620
10607
10621
self.message_router
10608
10622
.create_blinded_paths(recipient, context, peers, secp_ctx)
@@ -10617,20 +10631,7 @@ where
10617
10631
let recipient = self.get_our_node_id();
10618
10632
let secp_ctx = &self.secp_ctx;
10619
10633
10620
- let peers = self.per_peer_state.read().unwrap()
10621
- .iter()
10622
- .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
10623
- .filter(|(_, peer)| peer.is_connected)
10624
- .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
10625
- .map(|(node_id, peer)| MessageForwardNode {
10626
- node_id: *node_id,
10627
- short_channel_id: peer.channel_by_id
10628
- .iter()
10629
- .filter(|(_, channel)| channel.context().is_usable())
10630
- .min_by_key(|(_, channel)| channel.context().channel_creation_height)
10631
- .and_then(|(_, channel)| channel.context().get_short_channel_id()),
10632
- })
10633
- .collect::<Vec<_>>();
10634
+ let peers = self.get_peers_for_blinded_path();
10634
10635
10635
10636
self.message_router
10636
10637
.create_compact_blinded_paths(recipient, MessageContext::Offers(context), peers, secp_ctx)
0 commit comments