Merge pull request #2730 from benthecarman/invoice-utils
[rust-lightning] / lightning / src / chain / chainmonitor.rs
index aa9508d234fd899ac54b00d813425be8bfa4a324..0f128af4afffaf48cb4de4b384030bca4c547575 100644 (file)
@@ -324,7 +324,6 @@ where C::Target: chain::Filter,
                                if self.update_monitor_with_chain_data(header, best_height, txdata, &process, funding_outpoint, &monitor_state).is_err() {
                                        // Take the monitors lock for writing so that we poison it and any future
                                        // operations going forward fail immediately.
-                                       core::mem::drop(monitor_state);
                                        core::mem::drop(monitor_lock);
                                        let _poison = self.monitors.write().unwrap();
                                        log_error!(self.logger, "{}", err_str);
@@ -815,12 +814,7 @@ where C::Target: chain::Filter,
                let mut pending_monitor_events = self.pending_monitor_events.lock().unwrap().split_off(0);
                for monitor_state in self.monitors.read().unwrap().values() {
                        let is_pending_monitor_update = monitor_state.has_pending_chainsync_updates(&monitor_state.pending_monitor_updates.lock().unwrap());
-                       if is_pending_monitor_update &&
-                                       monitor_state.last_chain_persist_height.load(Ordering::Acquire) + LATENCY_GRACE_PERIOD_BLOCKS as usize
-                                               > self.highest_chain_height.load(Ordering::Acquire)
-                       {
-                               log_debug!(self.logger, "A Channel Monitor sync is still in progress, refusing to provide monitor events!");
-                       } else {
+                       if !is_pending_monitor_update || monitor_state.last_chain_persist_height.load(Ordering::Acquire) + LATENCY_GRACE_PERIOD_BLOCKS as usize <= self.highest_chain_height.load(Ordering::Acquire) {
                                if is_pending_monitor_update {
                                        log_error!(self.logger, "A ChannelMonitor sync took longer than {} blocks to complete.", LATENCY_GRACE_PERIOD_BLOCKS);
                                        log_error!(self.logger, "   To avoid funds-loss, we are allowing monitor updates to be released.");