X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fchain%2Fchainmonitor.rs;h=b47fd39087b3dbe92a29d1507b2ee8c952db3e96;hb=0ffa4b3579522c411be925203f192e26b0dd665e;hp=0a146c94084dc90a9fce36c6b9da01b8ab45049e;hpb=8861a9acfa612d5493235e0d275748cf6c56633d;p=rust-lightning diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index 0a146c94..b47fd390 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -31,7 +31,7 @@ use crate::chain::{ChannelMonitorUpdateStatus, Filter, WatchedOutput}; use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator}; use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, Balance, MonitorEvent, TransactionOutputs, WithChannelMonitor}; use crate::chain::transaction::{OutPoint, TransactionData}; -use crate::ln::ChannelId; +use crate::ln::types::ChannelId; use crate::sign::ecdsa::WriteableEcdsaChannelSigner; use crate::events; use crate::events::{Event, EventHandler}; @@ -231,6 +231,8 @@ pub struct ChainMonitor ) -> Result<(), ()> where FN: Fn(&ChannelMonitor, &TransactionData) -> Vec { let monitor = &monitor_state.monitor; - let logger = WithChannelMonitor::from(&self.logger, &monitor); + let logger = WithChannelMonitor::from(&self.logger, &monitor, None); let mut txn_outputs; { txn_outputs = process(monitor, txdata); @@ -597,7 +599,7 @@ where C::Target: chain::Filter, pub fn archive_fully_resolved_channel_monitors(&self) { let mut have_monitors_to_prune = false; for (_, monitor_holder) in self.monitors.read().unwrap().iter() { - let logger = WithChannelMonitor::from(&self.logger, &monitor_holder.monitor); + let logger = WithChannelMonitor::from(&self.logger, &monitor_holder.monitor, None); if monitor_holder.monitor.is_fully_resolved(&logger) { have_monitors_to_prune = true; } @@ -605,7 +607,7 @@ where C::Target: chain::Filter, if have_monitors_to_prune { let mut monitors = self.monitors.write().unwrap(); monitors.retain(|funding_txo, monitor_holder| { - let logger = WithChannelMonitor::from(&self.logger, &monitor_holder.monitor); + let logger = WithChannelMonitor::from(&self.logger, &monitor_holder.monitor, None); if monitor_holder.monitor.is_fully_resolved(&logger) { log_info!(logger, "Archiving fully resolved ChannelMonitor for funding txo {}", @@ -636,6 +638,8 @@ where monitor.block_connected( header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger) }); + // Assume we may have some new events and wake the event processor + self.event_notifier.notify(); } fn block_disconnected(&self, header: &Header, height: u32) { @@ -663,6 +667,8 @@ where monitor.transactions_confirmed( header, txdata, height, &*self.broadcaster, &*self.fee_estimator, &self.logger) }); + // Assume we may have some new events and wake the event processor + self.event_notifier.notify(); } fn transaction_unconfirmed(&self, txid: &Txid) { @@ -683,6 +689,8 @@ where header, height, &*self.broadcaster, &*self.fee_estimator, &self.logger ) }); + // Assume we may have some new events and wake the event processor + self.event_notifier.notify(); } fn get_relevant_txids(&self) -> Vec<(Txid, u32, Option)> { @@ -707,7 +715,7 @@ where C::Target: chain::Filter, P::Target: Persist, { fn watch_channel(&self, funding_outpoint: OutPoint, monitor: ChannelMonitor) -> Result { - let logger = WithChannelMonitor::from(&self.logger, &monitor); + let logger = WithChannelMonitor::from(&self.logger, &monitor, None); let mut monitors = self.monitors.write().unwrap(); let entry = match monitors.entry(funding_outpoint) { hash_map::Entry::Occupied(_) => { @@ -752,7 +760,7 @@ where C::Target: chain::Filter, let monitors = self.monitors.read().unwrap(); match monitors.get(&funding_txo) { None => { - let logger = WithContext::from(&self.logger, update.counterparty_node_id, Some(channel_id)); + let logger = WithContext::from(&self.logger, update.counterparty_node_id, Some(channel_id), None); log_error!(logger, "Failed to update channel monitor: no such monitor registered"); // We should never ever trigger this from within ChannelManager. Technically a @@ -765,7 +773,7 @@ where C::Target: chain::Filter, }, Some(monitor_state) => { let monitor = &monitor_state.monitor; - let logger = WithChannelMonitor::from(&self.logger, &monitor); + let logger = WithChannelMonitor::from(&self.logger, &monitor, None); log_trace!(logger, "Updating ChannelMonitor to id {} for channel {}", update.update_id, log_funding_info!(monitor)); let update_res = monitor.update_monitor(update, &self.broadcaster, &self.fee_estimator, &self.logger);