Skip to content

Commit 77f8725

Browse files
committed
Improving block connection logging and filtered txids
adding txid to filter and logging best_block_update adding txids to filter during runtime Rephrasing logging messages Improving message language
1 parent 20f287f commit 77f8725

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lightning/src/chain/chainmonitor.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ where C::Target: chain::Filter,
402402
outpoint: OutPoint { txid, index: idx as u16 },
403403
script_pubkey: output.script_pubkey,
404404
};
405-
chain_source.register_output(output)
405+
chain_source.register_output(output);
406+
log_trace!(self.logger, "Adding monitoring for spends of outpoint {}:{} to the filter", idx, txid);
406407
}
407408
}
408409
}
@@ -739,7 +740,7 @@ where C::Target: chain::Filter,
739740
},
740741
}
741742
if let Some(ref chain_source) = self.chain_source {
742-
monitor.load_outputs_to_watch(chain_source);
743+
monitor.load_outputs_to_watch(chain_source , &self.logger);
743744
}
744745
entry.insert(MonitorHolder {
745746
monitor,

lightning/src/chain/channelmonitor.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1343,9 +1343,13 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
13431343
/// Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly
13441344
/// calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs
13451345
/// have been registered.
1346-
pub fn load_outputs_to_watch<F: Deref>(&self, filter: &F) where F::Target: chain::Filter {
1346+
pub fn load_outputs_to_watch<F: Deref , L: Deref>(&self, filter: &F,logger: &L,)
1347+
where
1348+
F::Target: chain::Filter, L::Target: Logger,
1349+
{
13471350
let lock = self.inner.lock().unwrap();
13481351
filter.register_tx(&lock.get_funding_txo().0.txid, &lock.get_funding_txo().1);
1352+
log_trace!(logger, "registering funding outpoint {:?}" , &lock.get_funding_txo());
13491353
for (txid, outputs) in lock.get_outputs_to_watch().iter() {
13501354
for (index, script_pubkey) in outputs.iter() {
13511355
assert!(*index <= u16::max_value() as u32);
@@ -1354,6 +1358,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
13541358
outpoint: OutPoint { txid: *txid, index: *index as u16 },
13551359
script_pubkey: script_pubkey.clone(),
13561360
});
1361+
log_trace!(logger, "Adding monitoring for spends of outpoint {}:{} to the filter", index, txid);
13571362
}
13581363
}
13591364
}
@@ -3392,9 +3397,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
33923397

33933398
if height > self.best_block.height() {
33943399
self.best_block = BestBlock::new(block_hash, height);
3400+
log_trace!(logger, "Connecting new block {} at height {}", block_hash, height);
33953401
self.block_confirmed(height, block_hash, vec![], vec![], vec![], &broadcaster, &fee_estimator, &logger)
33963402
} else if block_hash != self.best_block.block_hash() {
33973403
self.best_block = BestBlock::new(block_hash, height);
3404+
log_trace!(logger, "New block of block hash {} has been found and updated", block_hash);
33983405
self.onchain_events_awaiting_threshold_conf.retain(|ref entry| entry.height <= height);
33993406
self.onchain_tx_handler.block_disconnected(height + 1, broadcaster, fee_estimator, logger);
34003407
Vec::new()
@@ -3431,6 +3438,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
34313438
let mut claimable_outpoints = Vec::new();
34323439
'tx_iter: for tx in &txn_matched {
34333440
let txid = tx.txid();
3441+
log_trace!(logger, "Transaction id {} confirmed in block {}", txid , block_hash);
34343442
// If a transaction has already been confirmed, ensure we don't bother processing it duplicatively.
34353443
if Some(txid) == self.funding_spend_confirmed {
34363444
log_debug!(logger, "Skipping redundant processing of funding-spend tx {} as it was previously confirmed", txid);

0 commit comments

Comments
 (0)