@@ -758,8 +758,9 @@ where C::Target: chain::Filter,
758758
759759	fn  update_channel ( & self ,  funding_txo :  OutPoint ,  update :  & ChannelMonitorUpdate )  -> ChannelMonitorUpdateStatus  { 
760760		// 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)  { 
763764			None  => { 
764765				log_error ! ( self . logger,  "Failed to update channel monitor: no such monitor registered" ) ; 
765766
@@ -798,29 +799,23 @@ where C::Target: chain::Filter,
798799					ChannelMonitorUpdateStatus :: Completed  => { 
799800						log_debug ! ( logger,  "Persistence of ChannelMonitorUpdate for channel {} completed" ,  log_funding_info!( monitor) ) ; 
800801					} , 
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+ 					} , 
802811				} 
803812				if  update_res. is_err ( )  { 
804813					ChannelMonitorUpdateStatus :: InProgress 
805814				}  else  { 
806815					persist_res
807816				} 
808817			} 
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) ; 
822818		} 
823- 		ret
824819	} 
825820
826821	fn  release_pending_monitor_events ( & self )  -> Vec < ( OutPoint ,  Vec < MonitorEvent > ,  Option < PublicKey > ) >  { 
0 commit comments