Skip to content

Commit e0be2ca

Browse files
committed
Move general channel behaviour into new ChannelInterface trait
In preparation for the introduction of `InboundChannel` and `OutboundChannel`, we move common channel behaviour and helpers to a new `ChannelInterface` trait. `Channel` and the upcoming prefunded channel types implement `ChannelInterface` and only need to provide a way to access their inner `ChannelContext`, mutably, and immutably, so that these can be called by default methods of the trait.
1 parent 2a5a37d commit e0be2ca

8 files changed

+295
-245
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor};
2020
use crate::chain::transaction::OutPoint;
2121
use crate::chain::{ChannelMonitorUpdateStatus, Listen, Watch};
2222
use crate::ln::channelmanager::{ChannelManager, RAACommitmentOrder, PaymentSendFailure, PaymentId};
23-
use crate::ln::channel::AnnouncementSigsState;
23+
use crate::ln::channel::{AnnouncementSigsState, ChannelInterface};
2424
use crate::ln::msgs;
2525
use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler};
2626
use crate::util::enforcing_trait_impls::EnforcingSigner;

lightning/src/ln/channel.rs

Lines changed: 288 additions & 240 deletions
Large diffs are not rendered by default.

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::chain::transaction::{OutPoint, TransactionData};
3838
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
3939
// construct one themselves.
4040
use crate::ln::{inbound_payment, PaymentHash, PaymentPreimage, PaymentSecret};
41-
use crate::ln::channel::{Channel, ChannelError, ChannelUpdateStatus, UpdateFulfillCommitFetch};
41+
use crate::ln::channel::{Channel, ChannelInterface, ChannelError, ChannelUpdateStatus, UpdateFulfillCommitFetch};
4242
use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
4343
#[cfg(any(feature = "_test_utils", test))]
4444
use crate::ln::features::InvoiceFeatures;

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch
1414
use crate::chain::channelmonitor::ChannelMonitor;
1515
use crate::chain::transaction::OutPoint;
1616
use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
17+
use crate::ln::channel::ChannelInterface;
1718
use crate::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA};
1819
use crate::routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate};
1920
use crate::routing::router::{self, PaymentParameters, Route};

lightning/src/ln/functional_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCK
1919
use crate::chain::transaction::OutPoint;
2020
use crate::chain::keysinterface::{ChannelSigner, EcdsaChannelSigner, EntropySource};
2121
use crate::ln::{PaymentPreimage, PaymentSecret, PaymentHash};
22-
use crate::ln::channel::{commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC, CONCURRENT_INBOUND_HTLC_FEE_BUFFER, FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE, MIN_AFFORDABLE_HTLC_COUNT};
22+
use crate::ln::channel::{ChannelInterface, commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC, CONCURRENT_INBOUND_HTLC_FEE_BUFFER, FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE, MIN_AFFORDABLE_HTLC_COUNT};
2323
use crate::ln::channelmanager::{self, PaymentId, RAACommitmentOrder, PaymentSendFailure, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA};
2424
use crate::ln::channel::{Channel, ChannelError};
2525
use crate::ln::{chan_utils, onion_utils};

lightning/src/ln/onion_route_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS};
1515
use crate::chain::keysinterface::{EntropySource, NodeSigner, Recipient};
1616
use crate::ln::{PaymentHash, PaymentSecret};
17-
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
17+
use crate::ln::channel::{ChannelInterface, EXPIRE_PREV_CONFIG_TICKS};
1818
use crate::ln::channelmanager::{HTLCForwardInfo, FailureCode, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingAddHTLCInfo, PendingHTLCInfo, PendingHTLCRouting, PaymentId};
1919
use crate::ln::onion_utils;
2020
use crate::routing::gossip::{NetworkUpdate, RoutingFees};

lightning/src/ln/payment_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Listen, Watch};
1515
use crate::chain::channelmonitor::{ANTI_REORG_DELAY, LATENCY_GRACE_PERIOD_BLOCKS};
1616
use crate::chain::keysinterface::EntropySource;
1717
use crate::chain::transaction::OutPoint;
18-
use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS;
18+
use crate::ln::channel::{ChannelInterface, EXPIRE_PREV_CONFIG_TICKS};
1919
use crate::ln::channelmanager::{BREAKDOWN_TIMEOUT, ChannelManager, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure, IDEMPOTENCY_TIMEOUT_TICKS, RecentPaymentDetails};
2020
use crate::ln::features::InvoiceFeatures;
2121
use crate::ln::msgs;

lightning/src/ln/shutdown_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
use crate::chain::keysinterface::{EntropySource, SignerProvider};
1313
use crate::chain::transaction::OutPoint;
14+
use crate::ln::channel::ChannelInterface;
1415
use crate::ln::channelmanager::{self, PaymentSendFailure, PaymentId};
1516
use crate::routing::router::{PaymentParameters, get_route};
1617
use crate::ln::msgs;

0 commit comments

Comments
 (0)