Skip to content

Commit 7753645

Browse files
committed
rustfmt: Run on util/macro_logger.rs
1 parent 7d6dc78 commit 7753645

File tree

1 file changed

+52
-25
lines changed

1 file changed

+52
-25
lines changed

lightning/src/util/macro_logger.rs

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@ use crate::sign::SpendableOutputDescriptor;
1212

1313
use bitcoin::transaction::Transaction;
1414

15-
use crate::routing::router::Route;
1615
use crate::ln::chan_utils::HTLCClaim;
16+
use crate::routing::router::Route;
1717

1818
macro_rules! log_iter {
1919
($obj: expr) => {
2020
$crate::util::logger::DebugIter($obj)
21-
}
21+
};
2222
}
2323

2424
/// Logs a pubkey in hex format.
2525
#[macro_export]
2626
macro_rules! log_pubkey {
2727
($obj: expr) => {
2828
$crate::util::logger::DebugPubKey(&$obj)
29-
}
29+
};
3030
}
3131

3232
/// Logs a byte slice in hex format.
3333
#[macro_export]
3434
macro_rules! log_bytes {
3535
($obj: expr) => {
3636
$crate::util::logger::DebugBytes(&$obj)
37-
}
37+
};
3838
}
3939

4040
pub(crate) struct DebugFundingInfo<'a>(pub &'a ChannelId);
@@ -45,10 +45,8 @@ impl<'a> core::fmt::Display for DebugFundingInfo<'a> {
4545
}
4646
macro_rules! log_funding_info {
4747
($key_storage: expr) => {
48-
$crate::util::macro_logger::DebugFundingInfo(
49-
&$key_storage.channel_id()
50-
)
51-
}
48+
$crate::util::macro_logger::DebugFundingInfo(&$key_storage.channel_id())
49+
};
5250
}
5351

5452
pub(crate) struct DebugRoute<'a>(pub &'a Route);
@@ -57,7 +55,14 @@ impl<'a> core::fmt::Display for DebugRoute<'a> {
5755
for (idx, p) in self.0.paths.iter().enumerate() {
5856
writeln!(f, "path {}:", idx)?;
5957
for h in p.hops.iter() {
60-
writeln!(f, " node_id: {}, short_channel_id: {}, fee_msat: {}, cltv_expiry_delta: {}", log_pubkey!(h.pubkey), h.short_channel_id, h.fee_msat, h.cltv_expiry_delta)?;
58+
writeln!(
59+
f,
60+
" node_id: {}, short_channel_id: {}, fee_msat: {}, cltv_expiry_delta: {}",
61+
log_pubkey!(h.pubkey),
62+
h.short_channel_id,
63+
h.fee_msat,
64+
h.cltv_expiry_delta
65+
)?;
6166
}
6267
writeln!(f, " blinded_tail: {:?}", p.blinded_tail)?;
6368
}
@@ -67,7 +72,7 @@ impl<'a> core::fmt::Display for DebugRoute<'a> {
6772
macro_rules! log_route {
6873
($obj: expr) => {
6974
$crate::util::macro_logger::DebugRoute(&$obj)
70-
}
75+
};
7176
}
7277

7378
pub(crate) struct DebugTx<'a>(pub &'a Transaction);
@@ -76,14 +81,21 @@ impl<'a> core::fmt::Display for DebugTx<'a> {
7681
if self.0.input.len() >= 1 && self.0.input.iter().any(|i| !i.witness.is_empty()) {
7782
let first_input = &self.0.input[0];
7883
let witness_script_len = first_input.witness.last().unwrap_or(&[]).len();
79-
if self.0.input.len() == 1 && witness_script_len == 71 &&
80-
(first_input.sequence.0 >> 8*3) as u8 == 0x80 {
84+
if self.0.input.len() == 1
85+
&& witness_script_len == 71
86+
&& (first_input.sequence.0 >> 8 * 3) as u8 == 0x80
87+
{
8188
write!(f, "commitment tx ")?;
8289
} else if self.0.input.len() == 1 && witness_script_len == 71 {
8390
write!(f, "closing tx ")?;
84-
} else if self.0.input.len() == 1 && HTLCClaim::from_witness(&first_input.witness) == Some(HTLCClaim::OfferedTimeout) {
91+
} else if self.0.input.len() == 1
92+
&& HTLCClaim::from_witness(&first_input.witness) == Some(HTLCClaim::OfferedTimeout)
93+
{
8594
write!(f, "HTLC-timeout tx ")?;
86-
} else if self.0.input.len() == 1 && HTLCClaim::from_witness(&first_input.witness) == Some(HTLCClaim::AcceptedPreimage) {
95+
} else if self.0.input.len() == 1
96+
&& HTLCClaim::from_witness(&first_input.witness)
97+
== Some(HTLCClaim::AcceptedPreimage)
98+
{
8799
write!(f, "HTLC-success tx ")?;
88100
} else {
89101
let mut num_preimage = 0;
@@ -92,15 +104,22 @@ impl<'a> core::fmt::Display for DebugTx<'a> {
92104
for inp in &self.0.input {
93105
let htlc_claim = HTLCClaim::from_witness(&inp.witness);
94106
match htlc_claim {
95-
Some(HTLCClaim::AcceptedPreimage)|Some(HTLCClaim::OfferedPreimage) => num_preimage += 1,
96-
Some(HTLCClaim::AcceptedTimeout)|Some(HTLCClaim::OfferedTimeout) => num_timeout += 1,
107+
Some(HTLCClaim::AcceptedPreimage) | Some(HTLCClaim::OfferedPreimage) => {
108+
num_preimage += 1
109+
},
110+
Some(HTLCClaim::AcceptedTimeout) | Some(HTLCClaim::OfferedTimeout) => {
111+
num_timeout += 1
112+
},
97113
Some(HTLCClaim::Revocation) => num_revoked += 1,
98114
None => continue,
99115
}
100116
}
101117
if num_preimage > 0 || num_timeout > 0 || num_revoked > 0 {
102-
write!(f, "HTLC claim tx ({} preimage, {} timeout, {} revoked) ",
103-
num_preimage, num_timeout, num_revoked)?;
118+
write!(
119+
f,
120+
"HTLC claim tx ({} preimage, {} timeout, {} revoked) ",
121+
num_preimage, num_timeout, num_revoked
122+
)?;
104123
}
105124
}
106125
} else {
@@ -115,7 +134,7 @@ impl<'a> core::fmt::Display for DebugTx<'a> {
115134
macro_rules! log_tx {
116135
($obj: expr) => {
117136
$crate::util::macro_logger::DebugTx(&$obj)
118-
}
137+
};
119138
}
120139

121140
pub(crate) struct DebugSpendable<'a>(pub &'a SpendableOutputDescriptor);
@@ -124,13 +143,21 @@ impl<'a> core::fmt::Display for DebugSpendable<'a> {
124143
match self.0 {
125144
&SpendableOutputDescriptor::StaticOutput { ref outpoint, .. } => {
126145
write!(f, "StaticOutput {}:{} marked for spending", outpoint.txid, outpoint.index)?;
127-
}
146+
},
128147
&SpendableOutputDescriptor::DelayedPaymentOutput(ref descriptor) => {
129-
write!(f, "DelayedPaymentOutput {}:{} marked for spending", descriptor.outpoint.txid, descriptor.outpoint.index)?;
130-
}
148+
write!(
149+
f,
150+
"DelayedPaymentOutput {}:{} marked for spending",
151+
descriptor.outpoint.txid, descriptor.outpoint.index
152+
)?;
153+
},
131154
&SpendableOutputDescriptor::StaticPaymentOutput(ref descriptor) => {
132-
write!(f, "StaticPaymentOutput {}:{} marked for spending", descriptor.outpoint.txid, descriptor.outpoint.index)?;
133-
}
155+
write!(
156+
f,
157+
"StaticPaymentOutput {}:{} marked for spending",
158+
descriptor.outpoint.txid, descriptor.outpoint.index
159+
)?;
160+
},
134161
}
135162
Ok(())
136163
}
@@ -139,7 +166,7 @@ impl<'a> core::fmt::Display for DebugSpendable<'a> {
139166
macro_rules! log_spendable {
140167
($obj: expr) => {
141168
$crate::util::macro_logger::DebugSpendable(&$obj)
142-
}
169+
};
143170
}
144171

145172
/// Create a new Record and log it. You probably don't want to use this macro directly,

0 commit comments

Comments
 (0)