Skip to content

Commit 1e0cfe9

Browse files
jkczyzdunxen
authored andcommitted
Remove #[rustfmt::skip] from FundedChannel::commitment_signed
1 parent 4227603 commit 1e0cfe9

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
@@ -6406,31 +6406,46 @@ where
64066406
Ok(channel_monitor)
64076407
}
64086408

6409-
#[rustfmt::skip]
6410-
pub fn commitment_signed<L: Deref>(&mut self, msg: &msgs::CommitmentSigned, logger: &L) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6411-
where L::Target: Logger
6409+
pub fn commitment_signed<L: Deref>(
6410+
&mut self, msg: &msgs::CommitmentSigned, logger: &L,
6411+
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6412+
where
6413+
L::Target: Logger,
64126414
{
64136415
self.commitment_signed_check_state()?;
64146416

64156417
if !self.pending_funding.is_empty() {
6416-
return Err(ChannelError::close("Got a single commitment_signed message when expecting a batch".to_owned()));
6418+
return Err(ChannelError::close(
6419+
"Got a single commitment_signed message when expecting a batch".to_owned(),
6420+
));
64176421
}
64186422

64196423
let updates = self
64206424
.context
64216425
.validate_commitment_signed(&self.funding, &self.holder_commitment_point, msg, logger)
6422-
.map(|LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs, nondust_htlc_sources }|
6423-
vec![ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6424-
commitment_tx, htlc_outputs, claimed_htlcs: vec![], nondust_htlc_sources,
6425-
}]
6426+
.map(
6427+
|LatestHolderCommitmentTXInfo {
6428+
commitment_tx,
6429+
htlc_outputs,
6430+
nondust_htlc_sources,
6431+
}| {
6432+
vec![ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6433+
commitment_tx,
6434+
htlc_outputs,
6435+
claimed_htlcs: vec![],
6436+
nondust_htlc_sources,
6437+
}]
6438+
},
64266439
)?;
64276440

64286441
self.commitment_signed_update_monitor(updates, logger)
64296442
}
64306443

6431-
#[rustfmt::skip]
6432-
pub fn commitment_signed_batch<L: Deref>(&mut self, batch: Vec<msgs::CommitmentSigned>, logger: &L) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6433-
where L::Target: Logger
6444+
pub fn commitment_signed_batch<L: Deref>(
6445+
&mut self, batch: Vec<msgs::CommitmentSigned>, logger: &L,
6446+
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6447+
where
6448+
L::Target: Logger,
64346449
{
64356450
self.commitment_signed_check_state()?;
64366451

@@ -6439,15 +6454,22 @@ where
64396454
let funding_txid = match msg.funding_txid {
64406455
Some(funding_txid) => funding_txid,
64416456
None => {
6442-
return Err(ChannelError::close("Peer sent batched commitment_signed without a funding_txid".to_string()));
6457+
return Err(ChannelError::close(
6458+
"Peer sent batched commitment_signed without a funding_txid".to_string(),
6459+
));
64436460
},
64446461
};
64456462

64466463
match messages.entry(funding_txid) {
6447-
btree_map::Entry::Vacant(entry) => { entry.insert(msg); },
6464+
btree_map::Entry::Vacant(entry) => {
6465+
entry.insert(msg);
6466+
},
64486467
btree_map::Entry::Occupied(_) => {
6449-
return Err(ChannelError::close(format!("Peer sent batched commitment_signed with duplicate funding_txid {}", funding_txid)));
6450-
}
6468+
return Err(ChannelError::close(format!(
6469+
"Peer sent batched commitment_signed with duplicate funding_txid {}",
6470+
funding_txid
6471+
)));
6472+
},
64516473
}
64526474
}
64536475

@@ -6457,36 +6479,56 @@ where
64576479
.chain(self.pending_funding.iter())
64586480
.map(|funding| {
64596481
let funding_txid = funding.get_funding_txo().unwrap().txid;
6460-
let msg = messages
6461-
.get(&funding_txid)
6462-
.ok_or_else(|| ChannelError::close(format!("Peer did not send a commitment_signed for pending splice transaction: {}", funding_txid)))?;
6482+
let msg = messages.get(&funding_txid).ok_or_else(|| {
6483+
ChannelError::close(format!(
6484+
"Peer did not send a commitment_signed for pending splice transaction: {}",
6485+
funding_txid
6486+
))
6487+
})?;
64636488
self.context
64646489
.validate_commitment_signed(funding, &self.holder_commitment_point, msg, logger)
6465-
.map(|LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs, nondust_htlc_sources }|
6466-
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6467-
commitment_tx, htlc_outputs, claimed_htlcs: vec![], nondust_htlc_sources,
6468-
}
6490+
.map(
6491+
|LatestHolderCommitmentTXInfo {
6492+
commitment_tx,
6493+
htlc_outputs,
6494+
nondust_htlc_sources,
6495+
}| ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6496+
commitment_tx,
6497+
htlc_outputs,
6498+
claimed_htlcs: vec![],
6499+
nondust_htlc_sources,
6500+
},
64696501
)
6470-
}
6471-
)
6502+
})
64726503
.collect::<Result<Vec<_>, ChannelError>>()?;
64736504

64746505
self.commitment_signed_update_monitor(updates, logger)
64756506
}
64766507

6477-
#[rustfmt::skip]
64786508
fn commitment_signed_check_state(&self) -> Result<(), ChannelError> {
64796509
if self.context.channel_state.is_quiescent() {
6480-
return Err(ChannelError::WarnAndDisconnect("Got commitment_signed message while quiescent".to_owned()));
6510+
return Err(ChannelError::WarnAndDisconnect(
6511+
"Got commitment_signed message while quiescent".to_owned(),
6512+
));
64816513
}
64826514
if !matches!(self.context.channel_state, ChannelState::ChannelReady(_)) {
6483-
return Err(ChannelError::close("Got commitment signed message when channel was not in an operational state".to_owned()));
6515+
return Err(ChannelError::close(
6516+
"Got commitment signed message when channel was not in an operational state"
6517+
.to_owned(),
6518+
));
64846519
}
64856520
if self.context.channel_state.is_peer_disconnected() {
6486-
return Err(ChannelError::close("Peer sent commitment_signed when we needed a channel_reestablish".to_owned()));
6521+
return Err(ChannelError::close(
6522+
"Peer sent commitment_signed when we needed a channel_reestablish".to_owned(),
6523+
));
64876524
}
6488-
if self.context.channel_state.is_both_sides_shutdown() && self.context.last_sent_closing_fee.is_some() {
6489-
return Err(ChannelError::close("Peer sent commitment_signed after we'd started exchanging closing_signeds".to_owned()));
6525+
if self.context.channel_state.is_both_sides_shutdown()
6526+
&& self.context.last_sent_closing_fee.is_some()
6527+
{
6528+
return Err(ChannelError::close(
6529+
"Peer sent commitment_signed after we'd started exchanging closing_signeds"
6530+
.to_owned(),
6531+
));
64906532
}
64916533

64926534
Ok(())

0 commit comments

Comments
 (0)