Skip to content

Commit bf34b5a

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 62b5493 commit bf34b5a

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/types.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -605,21 +605,21 @@ impl ChannelDetails {
605605
pub(crate) fn from_ldk(
606606
value: LdkChannelDetails, anchor_channels_config: Option<&AnchorChannelsConfig>,
607607
) -> Self {
608-
let is_anchor_channel =
609-
value.channel_type.as_ref().map_or(false, |ct| ct.supports_anchors_zero_fee_htlc_tx());
610-
611-
let reserve_type = if is_anchor_channel {
612-
let is_trusted = anchor_channels_config.map_or(false, |c| {
613-
c.trusted_peers_no_reserve.contains(&value.counterparty.node_id)
614-
});
615-
if is_trusted {
616-
ReserveType::TrustedPeersNoReserve
608+
let reserve_type =
609+
if value.channel_type.as_ref().is_some_and(|ct| ct.supports_anchors_zero_fee_htlc_tx())
610+
{
611+
if let Some(config) = anchor_channels_config {
612+
if config.trusted_peers_no_reserve.contains(&value.counterparty.node_id) {
613+
ReserveType::TrustedPeersNoReserve
614+
} else {
615+
ReserveType::Adaptive
616+
}
617+
} else {
618+
ReserveType::Adaptive
619+
}
617620
} else {
618-
ReserveType::Adaptive
619-
}
620-
} else {
621-
ReserveType::Legacy
622-
};
621+
ReserveType::Legacy
622+
};
623623

624624
ChannelDetails {
625625
channel_id: value.channel_id,

0 commit comments

Comments
 (0)