Skip to content

Commit 33a36bd

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 5289b18 commit 33a36bd

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
@@ -636,21 +636,21 @@ impl ChannelDetails {
636636
pub(crate) fn from_ldk(
637637
value: LdkChannelDetails, anchor_channels_config: Option<&AnchorChannelsConfig>,
638638
) -> Self {
639-
let is_anchor_channel =
640-
value.channel_type.as_ref().map_or(false, |ct| ct.supports_anchors_zero_fee_htlc_tx());
641-
642-
let reserve_type = if is_anchor_channel {
643-
let is_trusted = anchor_channels_config.map_or(false, |c| {
644-
c.trusted_peers_no_reserve.contains(&value.counterparty.node_id)
645-
});
646-
if is_trusted {
647-
ReserveType::TrustedPeersNoReserve
639+
let reserve_type =
640+
if value.channel_type.as_ref().is_some_and(|ct| ct.supports_anchors_zero_fee_htlc_tx())
641+
{
642+
if let Some(config) = anchor_channels_config {
643+
if config.trusted_peers_no_reserve.contains(&value.counterparty.node_id) {
644+
ReserveType::TrustedPeersNoReserve
645+
} else {
646+
ReserveType::Adaptive
647+
}
648+
} else {
649+
ReserveType::Adaptive
650+
}
648651
} else {
649-
ReserveType::Adaptive
650-
}
651-
} else {
652-
ReserveType::Legacy
653-
};
652+
ReserveType::Legacy
653+
};
654654

655655
ChannelDetails {
656656
channel_id: value.channel_id,

0 commit comments

Comments
 (0)