@@ -32,7 +32,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
3232use bitcoin:: hash_types:: { BlockHash , WPubkeyHash } ;
3333
3434use lightning:: chain;
35- use lightning:: chain:: { BestBlock , ChannelMonitorUpdateErr , chainmonitor, channelmonitor, Confirm , Watch } ;
35+ use lightning:: chain:: { BestBlock , ChannelMonitorUpdateStatus , chainmonitor, channelmonitor, Confirm , Watch } ;
3636use lightning:: chain:: channelmonitor:: { ChannelMonitor , MonitorEvent } ;
3737use lightning:: chain:: transaction:: OutPoint ;
3838use lightning:: chain:: chaininterface:: { BroadcasterInterface , ConfirmationTarget , FeeEstimator } ;
@@ -124,7 +124,7 @@ impl TestChainMonitor {
124124 }
125125}
126126impl chain:: Watch < EnforcingSigner > for TestChainMonitor {
127- fn watch_channel ( & self , funding_txo : OutPoint , monitor : channelmonitor:: ChannelMonitor < EnforcingSigner > ) -> Result < ( ) , chain:: ChannelMonitorUpdateErr > {
127+ fn watch_channel ( & self , funding_txo : OutPoint , monitor : channelmonitor:: ChannelMonitor < EnforcingSigner > ) -> chain:: ChannelMonitorUpdateStatus {
128128 let mut ser = VecWriter ( Vec :: new ( ) ) ;
129129 monitor. write ( & mut ser) . unwrap ( ) ;
130130 if let Some ( _) = self . latest_monitors . lock ( ) . unwrap ( ) . insert ( funding_txo, ( monitor. get_latest_update_id ( ) , ser. 0 ) ) {
@@ -134,7 +134,7 @@ impl chain::Watch<EnforcingSigner> for TestChainMonitor {
134134 self . chain_monitor . watch_channel ( funding_txo, monitor)
135135 }
136136
137- fn update_channel ( & self , funding_txo : OutPoint , update : channelmonitor:: ChannelMonitorUpdate ) -> Result < ( ) , chain:: ChannelMonitorUpdateErr > {
137+ fn update_channel ( & self , funding_txo : OutPoint , update : channelmonitor:: ChannelMonitorUpdate ) -> chain:: ChannelMonitorUpdateStatus {
138138 let mut map_lock = self . latest_monitors . lock ( ) . unwrap ( ) ;
139139 let mut map_entry = match map_lock. entry ( funding_txo) {
140140 hash_map:: Entry :: Occupied ( entry) => entry,
@@ -270,7 +270,7 @@ fn check_api_err(api_err: APIError) {
270270 _ => panic ! ( "{}" , err) ,
271271 }
272272 } ,
273- APIError :: MonitorUpdateFailed => {
273+ APIError :: MonitorUpdateInProgress => {
274274 // We can (obviously) temp-fail a monitor update
275275 } ,
276276 APIError :: IncompatibleShutdownScript { .. } => panic ! ( "Cannot send an incompatible shutdown script" ) ,
@@ -363,7 +363,9 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
363363 let logger: Arc <dyn Logger > = Arc :: new( test_logger:: TestLogger :: new( $node_id. to_string( ) , out. clone( ) ) ) ;
364364 let keys_manager = Arc :: new( KeyProvider { node_id: $node_id, rand_bytes_id: atomic:: AtomicU32 :: new( 0 ) , enforcement_states: Mutex :: new( HashMap :: new( ) ) } ) ;
365365 let monitor = Arc :: new( TestChainMonitor :: new( broadcast. clone( ) , logger. clone( ) , $fee_estimator. clone( ) ,
366- Arc :: new( TestPersister { update_ret: Mutex :: new( Ok ( ( ) ) ) } ) , Arc :: clone( & keys_manager) ) ) ;
366+ Arc :: new( TestPersister {
367+ update_ret: Mutex :: new( ChannelMonitorUpdateStatus :: Completed )
368+ } ) , Arc :: clone( & keys_manager) ) ) ;
367369
368370 let mut config = UserConfig :: default ( ) ;
369371 config. channel_config. forwarding_fee_proportional_millionths = 0 ;
@@ -383,7 +385,9 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
383385 let keys_manager = Arc :: clone( & $keys_manager) ;
384386 let logger: Arc <dyn Logger > = Arc :: new( test_logger:: TestLogger :: new( $node_id. to_string( ) , out. clone( ) ) ) ;
385387 let chain_monitor = Arc :: new( TestChainMonitor :: new( broadcast. clone( ) , logger. clone( ) , $fee_estimator. clone( ) ,
386- Arc :: new( TestPersister { update_ret: Mutex :: new( Ok ( ( ) ) ) } ) , Arc :: clone( & $keys_manager) ) ) ;
388+ Arc :: new( TestPersister {
389+ update_ret: Mutex :: new( ChannelMonitorUpdateStatus :: Completed )
390+ } ) , Arc :: clone( & $keys_manager) ) ) ;
387391
388392 let mut config = UserConfig :: default ( ) ;
389393 config. channel_config. forwarding_fee_proportional_millionths = 0 ;
@@ -412,7 +416,8 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
412416
413417 let res = ( <( BlockHash , ChanMan ) >:: read( & mut Cursor :: new( & $ser. 0 ) , read_args) . expect( "Failed to read manager" ) . 1 , chain_monitor. clone( ) ) ;
414418 for ( funding_txo, mon) in monitors. drain( ) {
415- assert!( chain_monitor. chain_monitor. watch_channel( funding_txo, mon) . is_ok( ) ) ;
419+ assert_eq!( chain_monitor. chain_monitor. watch_channel( funding_txo, mon) ,
420+ ChannelMonitorUpdateStatus :: Completed ) ;
416421 }
417422 res
418423 } }
@@ -889,12 +894,12 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
889894 // bit-twiddling mutations to have similar effects. This is probably overkill, but no
890895 // harm in doing so.
891896
892- 0x00 => * monitor_a. persister . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ,
893- 0x01 => * monitor_b. persister . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ,
894- 0x02 => * monitor_c. persister . update_ret . lock ( ) . unwrap ( ) = Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ,
895- 0x04 => * monitor_a. persister . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ,
896- 0x05 => * monitor_b. persister . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ,
897- 0x06 => * monitor_c. persister . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ,
897+ 0x00 => * monitor_a. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: InProgress ,
898+ 0x01 => * monitor_b. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: InProgress ,
899+ 0x02 => * monitor_c. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: InProgress ,
900+ 0x04 => * monitor_a. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: Completed ,
901+ 0x05 => * monitor_b. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: Completed ,
902+ 0x06 => * monitor_c. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: Completed ,
898903
899904 0x08 => {
900905 if let Some ( ( id, _) ) = monitor_a. latest_monitors . lock ( ) . unwrap ( ) . get ( & chan_1_funding) {
@@ -1119,9 +1124,9 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
11191124 // after we resolve all pending events.
11201125 // First make sure there are no pending monitor updates, resetting the error state
11211126 // and calling force_channel_monitor_updated for each monitor.
1122- * monitor_a. persister . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1123- * monitor_b. persister . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1124- * monitor_c. persister . update_ret . lock ( ) . unwrap ( ) = Ok ( ( ) ) ;
1127+ * monitor_a. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: Completed ;
1128+ * monitor_b. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: Completed ;
1129+ * monitor_c. persister . update_ret . lock ( ) . unwrap ( ) = ChannelMonitorUpdateStatus :: Completed ;
11251130
11261131 if let Some ( ( id, _) ) = monitor_a. latest_monitors . lock ( ) . unwrap ( ) . get ( & chan_1_funding) {
11271132 monitor_a. chain_monitor . force_channel_monitor_updated ( chan_1_funding, * id) ;
0 commit comments