Skip to content

Commit 698632e

Browse files
committed
Add ChannelPhase::is_funded for filtering channels.
Exposing ChannelPhase in ChannelManager has led to verbose match statements, which need to be modified each time a ChannelPhase is added. Making ChannelPhase an implementation detail of Channel would help avoid this. As a step in this direction, introduce ChannelPhase::is_funded for use in ChannelManager when a Channel (to be later renamed FundedChannel) needs to be tested for.
1 parent 1780ce4 commit 698632e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,10 @@ impl<'a, SP: Deref> ChannelPhase<SP> where
11531153
}
11541154
}
11551155

1156+
pub fn is_funded(&self) -> bool {
1157+
self.as_funded().is_some()
1158+
}
1159+
11561160
pub fn as_funded(&self) -> Option<&Channel<SP>> {
11571161
if let ChannelPhase::Funded(channel) = self {
11581162
Some(channel)

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,13 +1366,7 @@ impl <SP: Deref> PeerState<SP> where SP::Target: SignerProvider {
13661366
return false;
13671367
}
13681368
}
1369-
!self.channel_by_id.iter().any(|(_, phase)|
1370-
match phase {
1371-
ChannelPhase::Funded(_) | ChannelPhase::UnfundedOutboundV1(_) => true,
1372-
ChannelPhase::UnfundedInboundV1(_) => false,
1373-
ChannelPhase::UnfundedV2(chan) => chan.context.is_outbound(),
1374-
}
1375-
)
1369+
!self.channel_by_id.iter().any(|(_, channel)| channel.is_funded() || channel.context().is_outbound())
13761370
&& self.monitor_update_blocked_actions.is_empty()
13771371
&& self.closed_channel_monitor_update_ids.is_empty()
13781372
}

0 commit comments

Comments
 (0)