Skip to content

Commit 63f32ab

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 c02bcd3 commit 63f32ab

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

654654
ChannelDetails {
655655
channel_id: value.channel_id,

0 commit comments

Comments
 (0)