Skip to content

Commit 985a82b

Browse files
committed
Address review feedback: defer double-SHA256 computations in debug logging
Use a lazy Display wrapper to format confirmed txids, preventing unconditional hashing when DEBUG logging is disabled.
1 parent fdfef44 commit 985a82b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15968,8 +15968,14 @@ impl<
1596815968

1596915969
let block_hash = header.block_hash();
1597015970
log_trace!(self.logger, "{} transactions included in block {} at height {} provided", txdata.len(), block_hash, height);
15971+
struct LazyTxid<'a>(&'a Transaction);
15972+
impl<'a> core::fmt::Display for LazyTxid<'a> {
15973+
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
15974+
write!(f, "{}", self.0.compute_txid())
15975+
}
15976+
}
1597115977
for (_, tx) in txdata.iter() {
15972-
log_debug!(self.logger, "Confirmed transaction {} in block {} at height {}", tx.compute_txid(), block_hash, height);
15978+
log_debug!(self.logger, "Confirmed transaction {} in block {} at height {}", LazyTxid(tx), block_hash, height);
1597315979
}
1597415980

1597515981
let _persistence_guard =

0 commit comments

Comments
 (0)