Skip to content

Commit 1271cc9

Browse files
committed
f - split functions into multiple lines consistently
1 parent dfdddbf commit 1271cc9

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

lightning/src/ln/channel.rs

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
10741074

10751075
pub fn get_max_dust_htlc_exposure_msat<F: Deref>(&self,
10761076
_fee_estimator: &LowerBoundedFeeEstimator<F>) -> u64
1077-
where F::Target: FeeEstimator
1077+
where F::Target: FeeEstimator
10781078
{
10791079
match self.config.options.max_dust_htlc_exposure_msat {
10801080
MaxDustHTLCExposure::FixedLimitMsat(limit) => limit,
@@ -1553,8 +1553,9 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
15531553
/// Doesn't bother handling the
15541554
/// if-we-removed-it-already-but-haven't-fully-resolved-they-can-still-send-an-inbound-HTLC
15551555
/// corner case properly.
1556-
pub fn get_available_balances<F: Deref>(&self, fee_estimator: &LowerBoundedFeeEstimator<F>) -> AvailableBalances
1557-
where F::Target: FeeEstimator
1556+
pub fn get_available_balances<F: Deref>(&self, fee_estimator: &LowerBoundedFeeEstimator<F>)
1557+
-> AvailableBalances
1558+
where F::Target: FeeEstimator
15581559
{
15591560
let context = &self;
15601561
// Note that we have to handle overflow due to the above case.
@@ -2588,9 +2589,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
25882589
Ok(self.get_announcement_sigs(node_signer, genesis_block_hash, user_config, best_block.height(), logger))
25892590
}
25902591

2591-
pub fn update_add_htlc<F, FE: Deref, L: Deref>(&mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_status: PendingHTLCStatus, create_pending_htlc_status: F, fee_estimator: &LowerBoundedFeeEstimator<FE>, logger: &L) -> Result<(), ChannelError>
2592+
pub fn update_add_htlc<F, FE: Deref, L: Deref>(
2593+
&mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_status: PendingHTLCStatus,
2594+
create_pending_htlc_status: F, fee_estimator: &LowerBoundedFeeEstimator<FE>, logger: &L
2595+
) -> Result<(), ChannelError>
25922596
where F: for<'a> Fn(&'a Self, PendingHTLCStatus, u16) -> PendingHTLCStatus,
2593-
FE::Target: FeeEstimator, L::Target: Logger {
2597+
FE::Target: FeeEstimator, L::Target: Logger,
2598+
{
25942599
// We can't accept HTLCs sent after we've sent a shutdown.
25952600
let local_sent_shutdown = (self.context.channel_state & (ChannelState::ChannelReady as u32 | ChannelState::LocalShutdownSent as u32)) != (ChannelState::ChannelReady as u32);
25962601
if local_sent_shutdown {
@@ -3033,7 +3038,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
30333038
/// Public version of the below, checking relevant preconditions first.
30343039
/// If we're not in a state where freeing the holding cell makes sense, this is a no-op and
30353040
/// returns `(None, Vec::new())`.
3036-
pub fn maybe_free_holding_cell_htlcs<F: Deref, L: Deref>(&mut self, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L) -> (Option<&ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>) where F::Target: FeeEstimator, L::Target: Logger {
3041+
pub fn maybe_free_holding_cell_htlcs<F: Deref, L: Deref>(
3042+
&mut self, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
3043+
) -> (Option<&ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>)
3044+
where F::Target: FeeEstimator, L::Target: Logger
3045+
{
30373046
if self.context.channel_state >= ChannelState::ChannelReady as u32 &&
30383047
(self.context.channel_state & (ChannelState::AwaitingRemoteRevoke as u32 | ChannelState::PeerDisconnected as u32 | ChannelState::MonitorUpdateInProgress as u32)) == 0 {
30393048
self.free_holding_cell_htlcs(fee_estimator, logger)
@@ -3042,8 +3051,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
30423051

30433052
/// Frees any pending commitment updates in the holding cell, generating the relevant messages
30443053
/// for our counterparty.
3045-
fn free_holding_cell_htlcs<F: Deref, L: Deref>(&mut self, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L) -> (Option<&ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>)
3046-
where F::Target: FeeEstimator, L::Target: Logger
3054+
fn free_holding_cell_htlcs<F: Deref, L: Deref>(
3055+
&mut self, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
3056+
) -> (Option<&ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>)
3057+
where F::Target: FeeEstimator, L::Target: Logger
30473058
{
30483059
assert_eq!(self.context.channel_state & ChannelState::MonitorUpdateInProgress as u32, 0);
30493060
if self.context.holding_cell_htlc_updates.len() != 0 || self.context.holding_cell_update_fee.is_some() {
@@ -3160,8 +3171,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
31603171
/// waiting on this revoke_and_ack. The generation of this new commitment_signed may also fail,
31613172
/// generating an appropriate error *after* the channel state has been updated based on the
31623173
/// revoke_and_ack message.
3163-
pub fn revoke_and_ack<F: Deref, L: Deref>(&mut self, msg: &msgs::RevokeAndACK, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L) -> Result<(Vec<(HTLCSource, PaymentHash)>, Option<&ChannelMonitorUpdate>), ChannelError>
3164-
where F::Target: FeeEstimator, L::Target: Logger,
3174+
pub fn revoke_and_ack<F: Deref, L: Deref>(&mut self, msg: &msgs::RevokeAndACK,
3175+
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
3176+
) -> Result<(Vec<(HTLCSource, PaymentHash)>, Option<&ChannelMonitorUpdate>), ChannelError>
3177+
where F::Target: FeeEstimator, L::Target: Logger,
31653178
{
31663179
if (self.context.channel_state & (ChannelState::ChannelReady as u32)) != (ChannelState::ChannelReady as u32) {
31673180
return Err(ChannelError::Close("Got revoke/ACK message when channel was not in an operational state".to_owned()));
@@ -3399,7 +3412,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
33993412
/// commitment update.
34003413
pub fn queue_update_fee<F: Deref, L: Deref>(&mut self, feerate_per_kw: u32,
34013414
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L)
3402-
where F::Target: FeeEstimator, L::Target: Logger
3415+
where F::Target: FeeEstimator, L::Target: Logger
34033416
{
34043417
let msg_opt = self.send_update_fee(feerate_per_kw, true, fee_estimator, logger);
34053418
assert!(msg_opt.is_none(), "We forced holding cell?");
@@ -3412,7 +3425,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
34123425
///
34133426
/// You MUST call [`Self::send_commitment_no_state_update`] prior to any other calls on this
34143427
/// [`Channel`] if `force_holding_cell` is false.
3415-
fn send_update_fee<F: Deref, L: Deref>(&mut self, feerate_per_kw: u32, mut force_holding_cell: bool, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L) -> Option<msgs::UpdateFee>
3428+
fn send_update_fee<F: Deref, L: Deref>(
3429+
&mut self, feerate_per_kw: u32, mut force_holding_cell: bool,
3430+
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
3431+
) -> Option<msgs::UpdateFee>
34163432
where F::Target: FeeEstimator, L::Target: Logger
34173433
{
34183434
if !self.context.is_outbound() {
@@ -5076,7 +5092,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
50765092
onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
50775093
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
50785094
) -> Result<(), ChannelError>
5079-
where F::Target: FeeEstimator, L::Target: Logger
5095+
where F::Target: FeeEstimator, L::Target: Logger
50805096
{
50815097
self
50825098
.send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true,
@@ -5110,7 +5126,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
51105126
onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
51115127
skimmed_fee_msat: Option<u64>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
51125128
) -> Result<Option<msgs::UpdateAddHTLC>, ChannelError>
5113-
where F::Target: FeeEstimator, L::Target: Logger
5129+
where F::Target: FeeEstimator, L::Target: Logger
51145130
{
51155131
if (self.context.channel_state & (ChannelState::ChannelReady as u32 | BOTH_SIDES_SHUTDOWN_MASK)) != (ChannelState::ChannelReady as u32) {
51165132
return Err(ChannelError::Ignore("Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned()));
@@ -5325,11 +5341,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
53255341
/// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on
53265342
/// [`Self::send_htlc`] and [`Self::build_commitment_no_state_update`] for more info.
53275343
pub fn send_htlc_and_commit<F: Deref, L: Deref>(
5328-
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5329-
onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
5344+
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
5345+
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
53305346
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
53315347
) -> Result<Option<&ChannelMonitorUpdate>, ChannelError>
5332-
where F::Target: FeeEstimator, L::Target: Logger
5348+
where F::Target: FeeEstimator, L::Target: Logger
53335349
{
53345350
let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source,
53355351
onion_routing_packet, false, skimmed_fee_msat, fee_estimator, logger);

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,9 @@ impl ChannelDetails {
14971497

14981498
fn from_channel_context<Signer: WriteableEcdsaChannelSigner, F: Deref>(
14991499
context: &ChannelContext<Signer>, best_block_height: u32, latest_features: InitFeatures,
1500-
fee_estimator: &LowerBoundedFeeEstimator<F>) -> Self
1501-
where F::Target: FeeEstimator
1500+
fee_estimator: &LowerBoundedFeeEstimator<F>
1501+
) -> Self
1502+
where F::Target: FeeEstimator
15021503
{
15031504

15041505
let balance = context.get_available_balances(fee_estimator);

0 commit comments

Comments
 (0)