Skip to content

Commit 3cf83c1

Browse files
committed
Correcting the use of Box
1 parent 7a72560 commit 3cf83c1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lightning-invoice/src/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ fn sort_and_filter_channels<L: Deref>(
588588
channels: Vec<ChannelDetails>,
589589
min_inbound_capacity_msat: Option<u64>,
590590
logger: &L,
591-
) -> Box<dyn Iterator<Item = RouteHint>>
591+
) -> impl Iterator<Item = RouteHint>
592592
where
593593
L::Target: Logger,
594594
{
@@ -617,7 +617,7 @@ where
617617
// look at the public channels instead.
618618
log_trace!(logger, "Not including channels in invoice route hints on account of public channel {}",
619619
log_bytes!(channel.channel_id));
620-
return Box::new(vec![].into_iter());
620+
return vec![].into_iter().take(3).map(route_hint_from_channel);
621621
}
622622
}
623623

@@ -689,7 +689,8 @@ where
689689
cltv_expiry_delta: forwarding_info.cltv_expiry_delta,
690690
htlc_minimum_msat: channel.inbound_htlc_minimum_msat,
691691
htlc_maximum_msat: channel.inbound_htlc_maximum_msat,}])
692-
};
692+
693+
}
693694
// If all channels are private, prefer to return route hints which have a higher capacity than
694695
// the payment value and where we're currently connected to the channel counterparty.
695696
// Even if we cannot satisfy both goals, always ensure we include *some* hints, preferring
@@ -740,7 +741,7 @@ where
740741
b.inbound_capacity_msat.cmp(&a.inbound_capacity_msat)
741742
}});
742743

743-
Box::new(eligible_channels.into_iter().take(3).map(route_hint_from_channel))
744+
eligible_channels.into_iter().take(3).map(route_hint_from_channel)
744745
}
745746

746747
/// prefer_current_channel chooses a channel to use for route hints between a currently selected and candidate

0 commit comments

Comments
 (0)