@@ -758,8 +758,9 @@ where C::Target: chain::Filter,
758
758
759
759
fn update_channel ( & self , funding_txo : OutPoint , update : & ChannelMonitorUpdate ) -> ChannelMonitorUpdateStatus {
760
760
// Update the monitor that watches the channel referred to by the given outpoint.
761
- let monitors = self . monitors . read ( ) . unwrap ( ) ;
762
- let ret = match monitors. get ( & funding_txo) {
761
+ let monitors_lock = self . monitors . read ( ) . unwrap ( ) ;
762
+ let monitors = monitors_lock. deref ( ) ;
763
+ match monitors. get ( & funding_txo) {
763
764
None => {
764
765
log_error ! ( self . logger, "Failed to update channel monitor: no such monitor registered" ) ;
765
766
@@ -798,29 +799,23 @@ where C::Target: chain::Filter,
798
799
ChannelMonitorUpdateStatus :: Completed => {
799
800
log_debug ! ( logger, "Persistence of ChannelMonitorUpdate for channel {} completed" , log_funding_info!( monitor) ) ;
800
801
} ,
801
- ChannelMonitorUpdateStatus :: UnrecoverableError => { /* we'll panic in a moment */ } ,
802
+ ChannelMonitorUpdateStatus :: UnrecoverableError => {
803
+ // Take the monitors lock for writing so that we poison it and any future
804
+ // operations going forward fail immediately.
805
+ core:: mem:: drop ( monitors) ;
806
+ let _poison = self . monitors . write ( ) . unwrap ( ) ;
807
+ let err_str = "ChannelMonitor[Update] persistence failed unrecoverably. This indicates we cannot continue normal operation and must shut down." ;
808
+ log_error ! ( logger, "{}" , err_str) ;
809
+ panic ! ( "{}" , err_str) ;
810
+ } ,
802
811
}
803
812
if update_res. is_err ( ) {
804
813
ChannelMonitorUpdateStatus :: InProgress
805
814
} else {
806
815
persist_res
807
816
}
808
817
}
809
- } ;
810
- if let ChannelMonitorUpdateStatus :: UnrecoverableError = ret {
811
- let logger = WithChannelMonitor :: from (
812
- & self . logger , & monitors. get ( & funding_txo) . unwrap ( ) . monitor
813
- ) ;
814
-
815
- // Take the monitors lock for writing so that we poison it and any future
816
- // operations going forward fail immediately.
817
- core:: mem:: drop ( monitors) ;
818
- let _poison = self . monitors . write ( ) . unwrap ( ) ;
819
- let err_str = "ChannelMonitor[Update] persistence failed unrecoverably. This indicates we cannot continue normal operation and must shut down." ;
820
- log_error ! ( logger, "{}" , err_str) ;
821
- panic ! ( "{}" , err_str) ;
822
818
}
823
- ret
824
819
}
825
820
826
821
fn release_pending_monitor_events ( & self ) -> Vec < ( OutPoint , Vec < MonitorEvent > , Option < PublicKey > ) > {
0 commit comments