Skip to content

Commit a88bf56

Browse files
committed
Separate out channel context accessors into new trait
As multiple traits contain a context -- InitialRemoteCommitmentReceiver, FundingTxConstructor -- the context part is extracted into a separate new base trait, called ChannelContextProvider.
1 parent 7b45811 commit a88bf56

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lightning/src/ln/channel.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,13 +2103,15 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
21032103
is_holder_quiescence_initiator: Option<bool>,
21042104
}
21052105

2106-
/// A channel struct implementing this trait can receive an initial counterparty commitment
2107-
/// transaction signature.
2108-
trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvider {
2106+
/// A channel struct implementing this trait has a [`ChannelContext`], exposed through accessors.
2107+
pub(super) trait ChannelContextProvider<SP: Deref> where SP::Target: SignerProvider {
21092108
fn context(&self) -> &ChannelContext<SP>;
2110-
21112109
fn context_mut(&mut self) -> &mut ChannelContext<SP>;
2110+
}
21122111

2112+
/// A channel struct implementing this trait can receive an initial counterparty commitment
2113+
/// transaction signature.
2114+
trait InitialRemoteCommitmentReceiver<SP: Deref>: ChannelContextProvider<SP> where SP::Target: SignerProvider {
21132115
fn funding(&self) -> &FundingScope;
21142116

21152117
fn funding_mut(&mut self) -> &mut FundingScope;
@@ -2226,15 +2228,17 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
22262228
}
22272229
}
22282230

2229-
impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for OutboundV1Channel<SP> where SP::Target: SignerProvider {
2231+
impl<SP: Deref> ChannelContextProvider<SP> for OutboundV1Channel<SP> where SP::Target: SignerProvider {
22302232
fn context(&self) -> &ChannelContext<SP> {
22312233
&self.context
22322234
}
22332235

22342236
fn context_mut(&mut self) -> &mut ChannelContext<SP> {
22352237
&mut self.context
22362238
}
2239+
}
22372240

2241+
impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for OutboundV1Channel<SP> where SP::Target: SignerProvider {
22382242
fn funding(&self) -> &FundingScope {
22392243
&self.funding
22402244
}
@@ -2248,15 +2252,17 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for OutboundV1Channel<SP> wh
22482252
}
22492253
}
22502254

2251-
impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for InboundV1Channel<SP> where SP::Target: SignerProvider {
2255+
impl<SP: Deref> ChannelContextProvider<SP> for InboundV1Channel<SP> where SP::Target: SignerProvider {
22522256
fn context(&self) -> &ChannelContext<SP> {
22532257
&self.context
22542258
}
22552259

22562260
fn context_mut(&mut self) -> &mut ChannelContext<SP> {
22572261
&mut self.context
22582262
}
2263+
}
22592264

2265+
impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for InboundV1Channel<SP> where SP::Target: SignerProvider {
22602266
fn funding(&self) -> &FundingScope {
22612267
&self.funding
22622268
}
@@ -2270,15 +2276,19 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for InboundV1Channel<SP> whe
22702276
}
22712277
}
22722278

2273-
impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where SP::Target: SignerProvider {
2279+
impl<SP: Deref> ChannelContextProvider<SP> for FundedChannel<SP> where SP::Target: SignerProvider {
2280+
#[inline]
22742281
fn context(&self) -> &ChannelContext<SP> {
22752282
&self.context
22762283
}
22772284

2285+
#[inline]
22782286
fn context_mut(&mut self) -> &mut ChannelContext<SP> {
22792287
&mut self.context
22802288
}
2289+
}
22812290

2291+
impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where SP::Target: SignerProvider {
22822292
fn funding(&self) -> &FundingScope {
22832293
&self.funding
22842294
}

0 commit comments

Comments
 (0)