Skip to content

Commit c3ae30d

Browse files
committed
Implement From<PendingV2Channel> 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 PendingV2Channel to ChannelPhase (to be renamed Channel).
1 parent 232fcfb commit c3ae30d

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
@@ -1378,6 +1378,16 @@ where
13781378
}
13791379
}
13801380

1381+
impl<SP: Deref> From<PendingV2Channel<SP>> for ChannelPhase<SP>
1382+
where
1383+
SP::Target: SignerProvider,
1384+
<SP::Target as SignerProvider>::EcdsaSigner: ChannelSigner,
1385+
{
1386+
fn from(channel: PendingV2Channel<SP>) -> Self {
1387+
ChannelPhase::UnfundedV2(channel)
1388+
}
1389+
}
1390+
13811391
impl<SP: Deref> From<Channel<SP>> for ChannelPhase<SP>
13821392
where
13831393
SP::Target: SignerProvider,

lightning/src/ln/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7713,7 +7713,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
77137713
node_id: channel.context.get_counterparty_node_id(),
77147714
msg: channel.accept_inbound_dual_funded_channel()
77157715
};
7716-
(channel.context.channel_id(), ChannelPhase::UnfundedV2(channel), Some(message_send_event))
7716+
(channel.context.channel_id(), ChannelPhase::from(channel), Some(message_send_event))
77177717
})
77187718
},
77197719
}
@@ -7991,7 +7991,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
79917991
node_id: *counterparty_node_id,
79927992
msg: channel.accept_inbound_dual_funded_channel(),
79937993
};
7994-
(ChannelPhase::UnfundedV2(channel), Some(message_send_event))
7994+
(ChannelPhase::from(channel), Some(message_send_event))
79957995
},
79967996
};
79977997

0 commit comments

Comments
 (0)