Skip to content

Commit b2b0239

Browse files
committed
Respond to comments. Thanks @wpaulino!
1 parent 4c05087 commit b2b0239

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ impl<SP: Deref> Channel<SP> where
24912491
/// Handles a funding_signed message from the remote end.
24922492
/// If this call is successful, broadcast the funding transaction (and not before!)
24932493
pub fn funding_signed<L: Deref>(
2494-
&mut self, msg: &msgs::FundingSigned, best_block: BestBlock, signer_provider: SP, logger: &L
2494+
&mut self, msg: &msgs::FundingSigned, best_block: BestBlock, signer_provider: &SP, logger: &L
24952495
) -> Result<ChannelMonitor<<SP::Target as SignerProvider>::Signer>, ChannelError>
24962496
where
24972497
L::Target: Logger
@@ -4152,7 +4152,7 @@ impl<SP: Deref> Channel<SP> where
41524152
}
41534153

41544154
pub fn shutdown(
4155-
&mut self, signer_provider: SP, their_features: &InitFeatures, msg: &msgs::Shutdown
4155+
&mut self, signer_provider: &SP, their_features: &InitFeatures, msg: &msgs::Shutdown
41564156
) -> Result<(Option<msgs::Shutdown>, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), ChannelError>
41574157
{
41584158
if self.context.channel_state & (ChannelState::PeerDisconnected as u32) == ChannelState::PeerDisconnected as u32 {
@@ -5390,7 +5390,7 @@ impl<SP: Deref> Channel<SP> where
53905390
///
53915391
/// May jump to the channel being fully shutdown (see [`Self::is_shutdown`]) in which case no
53925392
/// [`ChannelMonitorUpdate`] will be returned).
5393-
pub fn get_shutdown(&mut self, signer_provider: SP, their_features: &InitFeatures,
5393+
pub fn get_shutdown(&mut self, signer_provider: &SP, their_features: &InitFeatures,
53945394
target_feerate_sats_per_kw: Option<u32>, override_shutdown_script: Option<ShutdownScript>)
53955395
-> Result<(msgs::Shutdown, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), APIError>
53965396
{
@@ -5511,7 +5511,7 @@ pub(super) struct OutboundV1Channel<SP: Deref> where SP::Target: SignerProvider
55115511

55125512
impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
55135513
pub fn new<ES: Deref, F: Deref>(
5514-
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: SP, counterparty_node_id: PublicKey, their_features: &InitFeatures,
5514+
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP, counterparty_node_id: PublicKey, their_features: &InitFeatures,
55155515
channel_value_satoshis: u64, push_msat: u64, user_id: u128, config: &UserConfig, current_chain_height: u32,
55165516
outbound_scid_alias: u64
55175517
) -> Result<OutboundV1Channel<SP>, APIError>
@@ -6020,7 +6020,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
60206020
/// Creates a new channel from a remote sides' request for one.
60216021
/// Assumes chain_hash has already been checked and corresponds with what we expect!
60226022
pub fn new<ES: Deref, F: Deref, L: Deref>(
6023-
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: SP,
6023+
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
60246024
counterparty_node_id: PublicKey, our_supported_features: &ChannelTypeFeatures,
60256025
their_features: &InitFeatures, msg: &msgs::OpenChannel, user_id: u128, config: &UserConfig,
60266026
current_chain_height: u32, logger: &L, outbound_scid_alias: u64
@@ -6457,7 +6457,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
64576457
}
64586458

64596459
pub fn funding_created<L: Deref>(
6460-
mut self, msg: &msgs::FundingCreated, best_block: BestBlock, signer_provider: SP, logger: &L
6460+
mut self, msg: &msgs::FundingCreated, best_block: BestBlock, signer_provider: &SP, logger: &L
64616461
) -> Result<(Channel<SP>, msgs::FundingSigned, ChannelMonitor<<SP::Target as SignerProvider>::Signer>), (Self, ChannelError)>
64626462
where
64636463
L::Target: Logger
@@ -7580,7 +7580,7 @@ mod tests {
75807580

75817581
let node_a_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
75827582
let config = UserConfig::default();
7583-
let node_a_chan = OutboundV1Channel::<&TestKeysInterface>::new(&bounded_fee_estimator, &&keys_provider, &keys_provider, node_a_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
7583+
let node_a_chan = OutboundV1Channel::<&TestKeysInterface>::new(&bounded_fee_estimator, &&keys_provider, &&keys_provider, node_a_node_id, &channelmanager::provided_init_features(&config), 10000000, 100000, 42, &config, 0, 42).unwrap();
75847584

75857585
// Now change the fee so we can check that the fee in the open_channel message is the
75867586
// same as the old fee.

lightning/src/ln/channelmanager.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ $vis trait AChannelManager {
790790
type NS: Deref<Target = Self::NodeSigner>;
791791
type Signer: WriteableEcdsaChannelSigner + Sized;
792792
type SignerProvider: SignerProvider<Signer = Self::Signer> + ?Sized;
793-
type SP: Deref<Target = Self::SignerProvider> + Clone;
793+
type SP: Deref<Target = Self::SignerProvider>;
794794
type FeeEstimator: FeeEstimator + ?Sized;
795795
type F: Deref<Target = Self::FeeEstimator>;
796796
type Router: Router + ?Sized;
@@ -804,7 +804,7 @@ $vis trait AChannelManager {
804804
define_test_pub_trait!(pub);
805805
#[cfg(not(any(test, feature = "_test_utils")))]
806806
define_test_pub_trait!(pub(crate));
807-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> AChannelManager
807+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> AChannelManager
808808
for ChannelManager<M, T, ES, NS, SP, F, R, L>
809809
where
810810
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
@@ -926,7 +926,7 @@ where
926926
// | |
927927
// | |__`pending_background_events`
928928
//
929-
pub struct ChannelManager<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref>
929+
pub struct ChannelManager<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
930930
where
931931
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
932932
T::Target: BroadcasterInterface,
@@ -2047,7 +2047,7 @@ macro_rules! process_events_body {
20472047
}
20482048
}
20492049

2050-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> ChannelManager<M, T, ES, NS, SP, F, R, L>
2050+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> ChannelManager<M, T, ES, NS, SP, F, R, L>
20512051
where
20522052
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
20532053
T::Target: BroadcasterInterface,
@@ -2202,7 +2202,7 @@ where
22022202
let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
22032203
let their_features = &peer_state.latest_features;
22042204
let config = if override_config.is_some() { override_config.as_ref().unwrap() } else { &self.default_configuration };
2205-
match OutboundV1Channel::new(&self.fee_estimator, &self.entropy_source, self.signer_provider.clone(), their_network_key,
2205+
match OutboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider, their_network_key,
22062206
their_features, channel_value_satoshis, push_msat, user_channel_id, config,
22072207
self.best_block.read().unwrap().height(), outbound_scid_alias)
22082208
{
@@ -2396,7 +2396,7 @@ where
23962396
let funding_txo_opt = chan_entry.get().context.get_funding_txo();
23972397
let their_features = &peer_state.latest_features;
23982398
let (shutdown_msg, mut monitor_update_opt, htlcs) = chan_entry.get_mut()
2399-
.get_shutdown(self.signer_provider.clone(), their_features, target_feerate_sats_per_1000_weight, override_shutdown_script)?;
2399+
.get_shutdown(&self.signer_provider, their_features, target_feerate_sats_per_1000_weight, override_shutdown_script)?;
24002400
failed_htlcs = htlcs;
24012401

24022402
// We can send the `shutdown` message before updating the `ChannelMonitor`
@@ -5314,7 +5314,7 @@ where
53145314
msg.temporary_channel_id.clone()));
53155315
}
53165316

5317-
let mut channel = match InboundV1Channel::new(&self.fee_estimator, &self.entropy_source, self.signer_provider.clone(),
5317+
let mut channel = match InboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
53185318
counterparty_node_id.clone(), &self.channel_type_features(), &peer_state.latest_features, msg, user_channel_id,
53195319
&self.default_configuration, best_block_height, &self.logger, outbound_scid_alias)
53205320
{
@@ -5401,7 +5401,7 @@ where
54015401
let (chan, funding_msg, monitor) =
54025402
match peer_state.inbound_v1_channel_by_id.remove(&msg.temporary_channel_id) {
54035403
Some(inbound_chan) => {
5404-
match inbound_chan.funding_created(msg, best_block, self.signer_provider.clone(), &self.logger) {
5404+
match inbound_chan.funding_created(msg, best_block, &self.signer_provider, &self.logger) {
54055405
Ok(res) => res,
54065406
Err((mut inbound_chan, err)) => {
54075407
// We've already removed this inbound channel from the map in `PeerState`
@@ -5480,7 +5480,7 @@ where
54805480
match peer_state.channel_by_id.entry(msg.channel_id) {
54815481
hash_map::Entry::Occupied(mut chan) => {
54825482
let monitor = try_chan_entry!(self,
5483-
chan.get_mut().funding_signed(&msg, best_block, self.signer_provider.clone(), &self.logger), chan);
5483+
chan.get_mut().funding_signed(&msg, best_block, &self.signer_provider, &self.logger), chan);
54845484
let update_res = self.chain_monitor.watch_channel(chan.get().context.get_funding_txo().unwrap(), monitor);
54855485
let mut res = handle_new_monitor_update!(self, update_res, peer_state_lock, peer_state, per_peer_state, chan, INITIAL_MONITOR);
54865486
if let Err(MsgHandleErrInternal { ref mut shutdown_finish, .. }) = res {
@@ -5576,7 +5576,7 @@ where
55765576

55775577
let funding_txo_opt = chan_entry.get().context.get_funding_txo();
55785578
let (shutdown, monitor_update_opt, htlcs) = try_chan_entry!(self,
5579-
chan_entry.get_mut().shutdown(self.signer_provider.clone(), &peer_state.latest_features, &msg), chan_entry);
5579+
chan_entry.get_mut().shutdown(&self.signer_provider, &peer_state.latest_features, &msg), chan_entry);
55805580
dropped_htlcs = htlcs;
55815581

55825582
if let Some(msg) = shutdown {
@@ -6601,7 +6601,7 @@ where
66016601
}
66026602
}
66036603

6604-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> MessageSendEventsProvider for ChannelManager<M, T, ES, NS, SP, F, R, L>
6604+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> MessageSendEventsProvider for ChannelManager<M, T, ES, NS, SP, F, R, L>
66056605
where
66066606
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
66076607
T::Target: BroadcasterInterface,
@@ -6663,7 +6663,7 @@ where
66636663
}
66646664
}
66656665

6666-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> EventsProvider for ChannelManager<M, T, ES, NS, SP, F, R, L>
6666+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> EventsProvider for ChannelManager<M, T, ES, NS, SP, F, R, L>
66676667
where
66686668
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
66696669
T::Target: BroadcasterInterface,
@@ -6684,7 +6684,7 @@ where
66846684
}
66856685
}
66866686

6687-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> chain::Listen for ChannelManager<M, T, ES, NS, SP, F, R, L>
6687+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> chain::Listen for ChannelManager<M, T, ES, NS, SP, F, R, L>
66886688
where
66896689
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
66906690
T::Target: BroadcasterInterface,
@@ -6725,7 +6725,7 @@ where
67256725
}
67266726
}
67276727

6728-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> chain::Confirm for ChannelManager<M, T, ES, NS, SP, F, R, L>
6728+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> chain::Confirm for ChannelManager<M, T, ES, NS, SP, F, R, L>
67296729
where
67306730
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
67316731
T::Target: BroadcasterInterface,
@@ -6820,7 +6820,7 @@ where
68206820
}
68216821
}
68226822

6823-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> ChannelManager<M, T, ES, NS, SP, F, R, L>
6823+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> ChannelManager<M, T, ES, NS, SP, F, R, L>
68246824
where
68256825
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
68266826
T::Target: BroadcasterInterface,
@@ -7040,7 +7040,7 @@ where
70407040
}
70417041
}
70427042

7043-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref>
7043+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
70447044
ChannelMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, L>
70457045
where
70467046
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
@@ -7892,7 +7892,7 @@ impl_writeable_tlv_based!(PendingInboundPayment, {
78927892
(8, min_value_msat, required),
78937893
});
78947894

7895-
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref> Writeable for ChannelManager<M, T, ES, NS, SP, F, R, L>
7895+
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref> Writeable for ChannelManager<M, T, ES, NS, SP, F, R, L>
78967896
where
78977897
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
78987898
T::Target: BroadcasterInterface,
@@ -8285,7 +8285,7 @@ where
82858285

82868286
// Implement ReadableArgs for an Arc'd ChannelManager to make it a bit easier to work with the
82878287
// SipmleArcChannelManager type:
8288-
impl<'a, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref>
8288+
impl<'a, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
82898289
ReadableArgs<ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, L>> for (BlockHash, Arc<ChannelManager<M, T, ES, NS, SP, F, R, L>>)
82908290
where
82918291
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,
@@ -8303,7 +8303,7 @@ where
83038303
}
83048304
}
83058305

8306-
impl<'a, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref + Clone, F: Deref, R: Deref, L: Deref>
8306+
impl<'a, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>
83078307
ReadableArgs<ChannelManagerReadArgs<'a, M, T, ES, NS, SP, F, R, L>> for (BlockHash, ChannelManager<M, T, ES, NS, SP, F, R, L>)
83088308
where
83098309
M::Target: chain::Watch<<SP::Target as SignerProvider>::Signer>,

lightning/src/ln/functional_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6965,7 +6965,7 @@ fn test_user_configurable_csv_delay() {
69656965

69666966
// We test config.our_to_self > BREAKDOWN_TIMEOUT is enforced in OutboundV1Channel::new()
69676967
if let Err(error) = OutboundV1Channel::new(&LowerBoundedFeeEstimator::new(&test_utils::TestFeeEstimator { sat_per_kw: Mutex::new(253) }),
6968-
&nodes[0].keys_manager, nodes[0].keys_manager, nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), 1000000, 1000000, 0,
6968+
&nodes[0].keys_manager, &nodes[0].keys_manager, nodes[1].node.get_our_node_id(), &nodes[1].node.init_features(), 1000000, 1000000, 0,
69696969
&low_our_to_self_config, 0, 42)
69706970
{
69716971
match error {
@@ -6979,7 +6979,7 @@ fn test_user_configurable_csv_delay() {
69796979
let mut open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id());
69806980
open_channel.to_self_delay = 200;
69816981
if let Err(error) = InboundV1Channel::new(&LowerBoundedFeeEstimator::new(&test_utils::TestFeeEstimator { sat_per_kw: Mutex::new(253) }),
6982-
&nodes[0].keys_manager, nodes[0].keys_manager, nodes[1].node.get_our_node_id(), &nodes[0].node.channel_type_features(), &nodes[1].node.init_features(), &open_channel, 0,
6982+
&nodes[0].keys_manager, &nodes[0].keys_manager, nodes[1].node.get_our_node_id(), &nodes[0].node.channel_type_features(), &nodes[1].node.init_features(), &open_channel, 0,
69836983
&low_our_to_self_config, 0, &nodes[0].logger, 42)
69846984
{
69856985
match error {
@@ -7011,7 +7011,7 @@ fn test_user_configurable_csv_delay() {
70117011
let mut open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id());
70127012
open_channel.to_self_delay = 200;
70137013
if let Err(error) = InboundV1Channel::new(&LowerBoundedFeeEstimator::new(&test_utils::TestFeeEstimator { sat_per_kw: Mutex::new(253) }),
7014-
&nodes[0].keys_manager, nodes[0].keys_manager, nodes[1].node.get_our_node_id(), &nodes[0].node.channel_type_features(), &nodes[1].node.init_features(), &open_channel, 0,
7014+
&nodes[0].keys_manager, &nodes[0].keys_manager, nodes[1].node.get_our_node_id(), &nodes[0].node.channel_type_features(), &nodes[1].node.init_features(), &open_channel, 0,
70157015
&high_their_to_self_config, 0, &nodes[0].logger, 42)
70167016
{
70177017
match error {

0 commit comments

Comments
 (0)