Skip to content

Commit d016801

Browse files
committed
Remove #[rustfmt::skip] from FundedChannel::commitment_signed
1 parent 5004ea9 commit d016801

File tree

1 file changed

+72
-30
lines changed

1 file changed

+72
-30
lines changed

lightning/src/ln/channel.rs

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6393,31 +6393,46 @@ where
63936393
Ok(channel_monitor)
63946394
}
63956395

6396-
#[rustfmt::skip]
6397-
pub fn commitment_signed<L: Deref>(&mut self, msg: &msgs::CommitmentSigned, logger: &L) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6398-
where L::Target: Logger
6396+
pub fn commitment_signed<L: Deref>(
6397+
&mut self, msg: &msgs::CommitmentSigned, logger: &L,
6398+
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6399+
where
6400+
L::Target: Logger,
63996401
{
64006402
self.commitment_signed_check_state()?;
64016403

64026404
if !self.pending_funding.is_empty() {
6403-
return Err(ChannelError::close("Got a single commitment_signed message when expecting a batch".to_owned()));
6405+
return Err(ChannelError::close(
6406+
"Got a single commitment_signed message when expecting a batch".to_owned(),
6407+
));
64046408
}
64056409

64066410
let updates = self
64076411
.context
64086412
.validate_commitment_signed(&self.funding, &self.holder_commitment_point, msg, logger)
6409-
.map(|LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs, nondust_htlc_sources }|
6410-
vec![ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6411-
commitment_tx, htlc_outputs, claimed_htlcs: vec![], nondust_htlc_sources,
6412-
}]
6413+
.map(
6414+
|LatestHolderCommitmentTXInfo {
6415+
commitment_tx,
6416+
htlc_outputs,
6417+
nondust_htlc_sources,
6418+
}| {
6419+
vec![ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6420+
commitment_tx,
6421+
htlc_outputs,
6422+
claimed_htlcs: vec![],
6423+
nondust_htlc_sources,
6424+
}]
6425+
},
64136426
)?;
64146427

64156428
self.commitment_signed_update_monitor(updates, logger)
64166429
}
64176430

6418-
#[rustfmt::skip]
6419-
pub fn commitment_signed_batch<L: Deref>(&mut self, batch: Vec<msgs::CommitmentSigned>, logger: &L) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6420-
where L::Target: Logger
6431+
pub fn commitment_signed_batch<L: Deref>(
6432+
&mut self, batch: Vec<msgs::CommitmentSigned>, logger: &L,
6433+
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6434+
where
6435+
L::Target: Logger,
64216436
{
64226437
self.commitment_signed_check_state()?;
64236438

@@ -6426,15 +6441,22 @@ where
64266441
let funding_txid = match msg.funding_txid {
64276442
Some(funding_txid) => funding_txid,
64286443
None => {
6429-
return Err(ChannelError::close("Peer sent batched commitment_signed without a funding_txid".to_string()));
6444+
return Err(ChannelError::close(
6445+
"Peer sent batched commitment_signed without a funding_txid".to_string(),
6446+
));
64306447
},
64316448
};
64326449

64336450
match messages.entry(funding_txid) {
6434-
btree_map::Entry::Vacant(entry) => { entry.insert(msg); },
6451+
btree_map::Entry::Vacant(entry) => {
6452+
entry.insert(msg);
6453+
},
64356454
btree_map::Entry::Occupied(_) => {
6436-
return Err(ChannelError::close(format!("Peer sent batched commitment_signed with duplicate funding_txid {}", funding_txid)));
6437-
}
6455+
return Err(ChannelError::close(format!(
6456+
"Peer sent batched commitment_signed with duplicate funding_txid {}",
6457+
funding_txid
6458+
)));
6459+
},
64386460
}
64396461
}
64406462

@@ -6444,36 +6466,56 @@ where
64446466
.chain(self.pending_funding.iter())
64456467
.map(|funding| {
64466468
let funding_txid = funding.get_funding_txo().unwrap().txid;
6447-
let msg = messages
6448-
.get(&funding_txid)
6449-
.ok_or_else(|| ChannelError::close(format!("Peer did not send a commitment_signed for pending splice transaction: {}", funding_txid)))?;
6469+
let msg = messages.get(&funding_txid).ok_or_else(|| {
6470+
ChannelError::close(format!(
6471+
"Peer did not send a commitment_signed for pending splice transaction: {}",
6472+
funding_txid
6473+
))
6474+
})?;
64506475
self.context
64516476
.validate_commitment_signed(funding, &self.holder_commitment_point, msg, logger)
6452-
.map(|LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs, nondust_htlc_sources }|
6453-
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6454-
commitment_tx, htlc_outputs, claimed_htlcs: vec![], nondust_htlc_sources,
6455-
}
6477+
.map(
6478+
|LatestHolderCommitmentTXInfo {
6479+
commitment_tx,
6480+
htlc_outputs,
6481+
nondust_htlc_sources,
6482+
}| ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6483+
commitment_tx,
6484+
htlc_outputs,
6485+
claimed_htlcs: vec![],
6486+
nondust_htlc_sources,
6487+
},
64566488
)
6457-
}
6458-
)
6489+
})
64596490
.collect::<Result<Vec<_>, ChannelError>>()?;
64606491

64616492
self.commitment_signed_update_monitor(updates, logger)
64626493
}
64636494

6464-
#[rustfmt::skip]
64656495
fn commitment_signed_check_state(&self) -> Result<(), ChannelError> {
64666496
if self.context.channel_state.is_quiescent() {
6467-
return Err(ChannelError::WarnAndDisconnect("Got commitment_signed message while quiescent".to_owned()));
6497+
return Err(ChannelError::WarnAndDisconnect(
6498+
"Got commitment_signed message while quiescent".to_owned(),
6499+
));
64686500
}
64696501
if !matches!(self.context.channel_state, ChannelState::ChannelReady(_)) {
6470-
return Err(ChannelError::close("Got commitment signed message when channel was not in an operational state".to_owned()));
6502+
return Err(ChannelError::close(
6503+
"Got commitment signed message when channel was not in an operational state"
6504+
.to_owned(),
6505+
));
64716506
}
64726507
if self.context.channel_state.is_peer_disconnected() {
6473-
return Err(ChannelError::close("Peer sent commitment_signed when we needed a channel_reestablish".to_owned()));
6508+
return Err(ChannelError::close(
6509+
"Peer sent commitment_signed when we needed a channel_reestablish".to_owned(),
6510+
));
64746511
}
6475-
if self.context.channel_state.is_both_sides_shutdown() && self.context.last_sent_closing_fee.is_some() {
6476-
return Err(ChannelError::close("Peer sent commitment_signed after we'd started exchanging closing_signeds".to_owned()));
6512+
if self.context.channel_state.is_both_sides_shutdown()
6513+
&& self.context.last_sent_closing_fee.is_some()
6514+
{
6515+
return Err(ChannelError::close(
6516+
"Peer sent commitment_signed after we'd started exchanging closing_signeds"
6517+
.to_owned(),
6518+
));
64776519
}
64786520

64796521
Ok(())

0 commit comments

Comments
 (0)