Skip to content

Commit 232fcfb

Browse files
committed
Implement From<InboundV1Channel> for ChannelPhase
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, define a conversion from InboundV1Channel to ChannelPhase (to be renamed Channel).
1 parent 07da6c1 commit 232fcfb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lightning/src/ln/channel.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,16 @@ where
13681368
}
13691369
}
13701370

1371+
impl<SP: Deref> From<InboundV1Channel<SP>> for ChannelPhase<SP>
1372+
where
1373+
SP::Target: SignerProvider,
1374+
<SP::Target as SignerProvider>::EcdsaSigner: ChannelSigner,
1375+
{
1376+
fn from(channel: InboundV1Channel<SP>) -> Self {
1377+
ChannelPhase::UnfundedInboundV1(channel)
1378+
}
1379+
}
1380+
13711381
impl<SP: Deref> From<Channel<SP>> for ChannelPhase<SP>
13721382
where
13731383
SP::Target: SignerProvider,

lightning/src/ln/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7689,7 +7689,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
76897689
msg,
76907690
}
76917691
});
7692-
(*temporary_channel_id, ChannelPhase::UnfundedInboundV1(channel), message_send_event)
7692+
(*temporary_channel_id, ChannelPhase::from(channel), message_send_event)
76937693
})
76947694
},
76957695
#[cfg(dual_funding)]
@@ -7977,7 +7977,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
79777977
msg,
79787978
}
79797979
});
7980-
(ChannelPhase::UnfundedInboundV1(channel), message_send_event)
7980+
(ChannelPhase::from(channel), message_send_event)
79817981
},
79827982
#[cfg(dual_funding)]
79837983
OpenChannelMessageRef::V2(msg) => {

0 commit comments

Comments
 (0)