Skip to content

Commit a26083e

Browse files
committed
Use Vec instead of HashSet.
1 parent 2d73ec1 commit a26083e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lightning/src/routing/router.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,8 +1565,8 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
15651565
let mut shadow_ctlv_expiry_delta_offset: u32 = 0;
15661566

15671567
// Mark all nodes on the actual path as visited to avoid looping random walks.
1568-
let mut visited_nodes: HashSet<NodeId> = HashSet::new();
1569-
path.iter().for_each(|h| { visited_nodes.insert(NodeId::from_pubkey(&h.pubkey)); });
1568+
let mut visited_nodes: Vec<NodeId> = path.iter()
1569+
.map(|h| NodeId::from_pubkey(&h.pubkey)).collect();
15701570

15711571
// Choose the last publicly known node as the starting point for the random walk.
15721572
let mut cur_hop: Option<NodeId> = None;
@@ -1599,7 +1599,8 @@ fn add_random_cltv_offset(route: &mut Route, payment_params: &PaymentParameters,
15991599
.and_then(|index| cur_node.channels.get(index))
16001600
.and_then(|id| network_channels.get(id)) {
16011601
random_channel.as_directed_from(&cur_node_id).map(|(dir_info, next_id)| {
1602-
if visited_nodes.insert(*next_id) {
1602+
if !visited_nodes.contains(next_id) {
1603+
visited_nodes.push(*next_id);
16031604
dir_info.direction().map(|channel_update_info| {
16041605
random_hop_offset = channel_update_info.cltv_expiry_delta.into();
16051606
cur_hop = Some(*next_id);

0 commit comments

Comments
 (0)