- fn add_update_monitor(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor<EnforcingChannelKeys>) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
- let ret = self.update_ret.lock().unwrap().clone();
- if let Ok(()) = ret {
- let mut ser = VecWriter(Vec::new());
- monitor.write_for_disk(&mut ser).unwrap();
- self.latest_good_update.lock().unwrap().insert(funding_txo, ser.0);
- match self.latest_update_good.lock().unwrap().entry(funding_txo) {
- hash_map::Entry::Vacant(e) => { e.insert(true); },
- hash_map::Entry::Occupied(mut e) => {
- if !e.get() && unsafe { IN_RESTORE } {
- // Technically we can't consider an update to be "good" unless we're doing
- // it in response to a test_restore_channel_monitor as the channel may
- // still be waiting on such a call, so only set us to good if we're in the
- // middle of a restore call.
- e.insert(true);
- }
- },
- }
- self.should_update_manager.store(true, atomic::Ordering::Relaxed);
- } else {
- self.latest_update_good.lock().unwrap().insert(funding_txo, false);
+ fn add_monitor(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor<EnforcingChannelKeys>) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
+ let mut ser = VecWriter(Vec::new());
+ monitor.write_for_disk(&mut ser).unwrap();
+ if let Some(_) = self.latest_monitors.lock().unwrap().insert(funding_txo, (monitor.get_latest_update_id(), ser.0)) {
+ panic!("Already had monitor pre-add_monitor");