From 2f3c0f947b9c53b4c3387c458e4985d1ae429deb Mon Sep 17 00:00:00 2001 From: Alec Chen Date: Thu, 22 Jun 2023 14:06:03 -0500 Subject: [PATCH] f - split functions into multiple lines consistently --- lightning/src/ln/channel.rs | 44 ++++++++++++++++++++---------- lightning/src/ln/channelmanager.rs | 5 ++-- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 12f2cc36be0..b9b6de1b2c9 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -1061,7 +1061,7 @@ impl ChannelContext { pub fn get_max_dust_htlc_exposure_msat(&self, _fee_estimator: &LowerBoundedFeeEstimator) -> u64 - where F::Target: FeeEstimator + where F::Target: FeeEstimator { match self.config.options.max_dust_htlc_exposure_msat { MaxDustHTLCExposure::FixedLimitMsat(limit) => limit, @@ -1539,8 +1539,9 @@ impl ChannelContext { /// Doesn't bother handling the /// if-we-removed-it-already-but-haven't-fully-resolved-they-can-still-send-an-inbound-HTLC /// corner case properly. - pub fn get_available_balances(&self, fee_estimator: &LowerBoundedFeeEstimator) -> AvailableBalances - where F::Target: FeeEstimator + pub fn get_available_balances(&self, fee_estimator: &LowerBoundedFeeEstimator) + -> AvailableBalances + where F::Target: FeeEstimator { let context = &self; // Note that we have to handle overflow due to the above case. @@ -2561,9 +2562,13 @@ impl Channel { Ok(self.get_announcement_sigs(node_signer, genesis_block_hash, user_config, best_block.height(), logger)) } - pub fn update_add_htlc(&mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_status: PendingHTLCStatus, create_pending_htlc_status: F, fee_estimator: &LowerBoundedFeeEstimator, logger: &L) -> Result<(), ChannelError> + pub fn update_add_htlc( + &mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_status: PendingHTLCStatus, + create_pending_htlc_status: F, fee_estimator: &LowerBoundedFeeEstimator, logger: &L + ) -> Result<(), ChannelError> where F: for<'a> Fn(&'a Self, PendingHTLCStatus, u16) -> PendingHTLCStatus, - FE::Target: FeeEstimator, L::Target: Logger { + FE::Target: FeeEstimator, L::Target: Logger, + { // We can't accept HTLCs sent after we've sent a shutdown. let local_sent_shutdown = (self.context.channel_state & (ChannelState::ChannelReady as u32 | ChannelState::LocalShutdownSent as u32)) != (ChannelState::ChannelReady as u32); if local_sent_shutdown { @@ -3006,7 +3011,11 @@ impl Channel { /// Public version of the below, checking relevant preconditions first. /// If we're not in a state where freeing the holding cell makes sense, this is a no-op and /// returns `(None, Vec::new())`. - pub fn maybe_free_holding_cell_htlcs(&mut self, fee_estimator: &LowerBoundedFeeEstimator, logger: &L) -> (Option, Vec<(HTLCSource, PaymentHash)>) where F::Target: FeeEstimator, L::Target: Logger { + pub fn maybe_free_holding_cell_htlcs( + &mut self, fee_estimator: &LowerBoundedFeeEstimator, logger: &L + ) -> (Option, Vec<(HTLCSource, PaymentHash)>) + where F::Target: FeeEstimator, L::Target: Logger + { if self.context.channel_state >= ChannelState::ChannelReady as u32 && (self.context.channel_state & (ChannelState::AwaitingRemoteRevoke as u32 | ChannelState::PeerDisconnected as u32 | ChannelState::MonitorUpdateInProgress as u32)) == 0 { self.free_holding_cell_htlcs(fee_estimator, logger) @@ -3015,7 +3024,9 @@ impl Channel { /// Frees any pending commitment updates in the holding cell, generating the relevant messages /// for our counterparty. - fn free_holding_cell_htlcs(&mut self, fee_estimator: &LowerBoundedFeeEstimator, logger: &L) -> (Option, Vec<(HTLCSource, PaymentHash)>) + fn free_holding_cell_htlcs( + &mut self, fee_estimator: &LowerBoundedFeeEstimator, logger: &L + ) -> (Option, Vec<(HTLCSource, PaymentHash)>) where F::Target: FeeEstimator, L::Target: Logger { assert_eq!(self.context.channel_state & ChannelState::MonitorUpdateInProgress as u32, 0); @@ -3133,7 +3144,9 @@ impl Channel { /// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail, /// generating an appropriate error *after* the channel state has been updated based on the /// revoke_and_ack message. - pub fn revoke_and_ack(&mut self, msg: &msgs::RevokeAndACK, fee_estimator: &LowerBoundedFeeEstimator, logger: &L) -> Result<(Vec<(HTLCSource, PaymentHash)>, Option), ChannelError> + pub fn revoke_and_ack(&mut self, msg: &msgs::RevokeAndACK, + fee_estimator: &LowerBoundedFeeEstimator, logger: &L + ) -> Result<(Vec<(HTLCSource, PaymentHash)>, Option), ChannelError> where F::Target: FeeEstimator, L::Target: Logger, { if (self.context.channel_state & (ChannelState::ChannelReady as u32)) != (ChannelState::ChannelReady as u32) { @@ -3371,7 +3384,7 @@ impl Channel { /// commitment update. pub fn queue_update_fee(&mut self, feerate_per_kw: u32, fee_estimator: &LowerBoundedFeeEstimator, logger: &L) - where F::Target: FeeEstimator, L::Target: Logger + where F::Target: FeeEstimator, L::Target: Logger { let msg_opt = self.send_update_fee(feerate_per_kw, true, fee_estimator, logger); assert!(msg_opt.is_none(), "We forced holding cell?"); @@ -3384,7 +3397,10 @@ impl Channel { /// /// You MUST call [`Self::send_commitment_no_state_update`] prior to any other calls on this /// [`Channel`] if `force_holding_cell` is false. - fn send_update_fee(&mut self, feerate_per_kw: u32, mut force_holding_cell: bool, fee_estimator: &LowerBoundedFeeEstimator, logger: &L) -> Option + fn send_update_fee( + &mut self, feerate_per_kw: u32, mut force_holding_cell: bool, + fee_estimator: &LowerBoundedFeeEstimator, logger: &L + ) -> Option where F::Target: FeeEstimator, L::Target: Logger { if !self.context.is_outbound() { @@ -5013,7 +5029,7 @@ impl Channel { onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option, fee_estimator: &LowerBoundedFeeEstimator, logger: &L ) -> Result<(), ChannelError> - where F::Target: FeeEstimator, L::Target: Logger + where F::Target: FeeEstimator, L::Target: Logger { self .send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true, @@ -5047,7 +5063,7 @@ impl Channel { onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool, skimmed_fee_msat: Option, fee_estimator: &LowerBoundedFeeEstimator, logger: &L ) -> Result, ChannelError> - where F::Target: FeeEstimator, L::Target: Logger + where F::Target: FeeEstimator, L::Target: Logger { if (self.context.channel_state & (ChannelState::ChannelReady as u32 | BOTH_SIDES_SHUTDOWN_MASK)) != (ChannelState::ChannelReady as u32) { return Err(ChannelError::Ignore("Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned())); @@ -5262,8 +5278,8 @@ impl Channel { /// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on /// [`Self::send_htlc`] and [`Self::build_commitment_no_state_update`] for more info. pub fn send_htlc_and_commit( - &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource, - onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option, + &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, + source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option, fee_estimator: &LowerBoundedFeeEstimator, logger: &L ) -> Result, ChannelError> where F::Target: FeeEstimator, L::Target: Logger diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 6d56173bee9..b284937f5e4 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -1505,8 +1505,9 @@ impl ChannelDetails { fn from_channel_context( context: &ChannelContext, best_block_height: u32, latest_features: InitFeatures, - fee_estimator: &LowerBoundedFeeEstimator) -> Self - where F::Target: FeeEstimator + fee_estimator: &LowerBoundedFeeEstimator + ) -> Self + where F::Target: FeeEstimator { let balance = context.get_available_balances(fee_estimator);