Skip to content

Commit 78a492c

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 49c25f3 commit 78a492c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,16 @@ where
13561356
}
13571357
}
13581358

1359+
impl<SP: Deref> From<InboundV1Channel<SP>> for ChannelPhase<SP>
1360+
where
1361+
SP::Target: SignerProvider,
1362+
<SP::Target as SignerProvider>::EcdsaSigner: ChannelSigner,
1363+
{
1364+
fn from(channel: InboundV1Channel<SP>) -> Self {
1365+
ChannelPhase::UnfundedInboundV1(channel)
1366+
}
1367+
}
1368+
13591369
impl<SP: Deref> From<Channel<SP>> for ChannelPhase<SP>
13601370
where
13611371
SP::Target: SignerProvider,

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
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)