Skip to content

Commit afde0ce

Browse files
committed
fixup! Add ReserveType to ChannelDetails
Simplify ReserveType resolution by using `if let Some` for the anchor channels config instead of intermediate bools and `map_or`.
1 parent 40c7b46 commit afde0ce

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/types.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -637,21 +637,21 @@ impl ChannelDetails {
637637
pub(crate) fn from_ldk(
638638
value: LdkChannelDetails, anchor_channels_config: Option<&AnchorChannelsConfig>,
639639
) -> Self {
640-
let is_anchor_channel =
641-
value.channel_type.as_ref().map_or(false, |ct| ct.supports_anchors_zero_fee_htlc_tx());
642-
643-
let reserve_type = if is_anchor_channel {
644-
let is_trusted = anchor_channels_config.map_or(false, |c| {
645-
c.trusted_peers_no_reserve.contains(&value.counterparty.node_id)
646-
});
647-
if is_trusted {
648-
ReserveType::TrustedPeersNoReserve
640+
let reserve_type =
641+
if value.channel_type.as_ref().is_some_and(|ct| ct.supports_anchors_zero_fee_htlc_tx())
642+
{
643+
if let Some(config) = anchor_channels_config {
644+
if config.trusted_peers_no_reserve.contains(&value.counterparty.node_id) {
645+
ReserveType::TrustedPeersNoReserve
646+
} else {
647+
ReserveType::Adaptive
648+
}
649+
} else {
650+
ReserveType::Adaptive
651+
}
649652
} else {
650-
ReserveType::Adaptive
651-
}
652-
} else {
653-
ReserveType::Legacy
654-
};
653+
ReserveType::Legacy
654+
};
655655

656656
ChannelDetails {
657657
channel_id: value.channel_id,

0 commit comments

Comments
 (0)