@@ -122,7 +122,10 @@ impl Scanners {
122122 } ) ;
123123 }
124124
125- Self :: start_correct_payable_scanner :: < ScanForNewPayables > (
125+ <( dyn MultistageDualPayableScanner ) as StartableScanner <
126+ ScanForNewPayables ,
127+ InitialTemplatesMessage ,
128+ > >:: start_scan (
126129 & mut * self . payable ,
127130 wallet,
128131 timestamp,
@@ -150,7 +153,10 @@ impl Scanners {
150153 )
151154 }
152155
153- Self :: start_correct_payable_scanner :: < ScanForRetryPayables > (
156+ <( dyn MultistageDualPayableScanner ) as StartableScanner <
157+ ScanForRetryPayables ,
158+ InitialTemplatesMessage ,
159+ > >:: start_scan (
154160 & mut * self . payable ,
155161 wallet,
156162 timestamp,
@@ -168,10 +174,14 @@ impl Scanners {
168174 automatic_scans_enabled : bool ,
169175 ) -> Result < RequestTransactionReceipts , StartScanError > {
170176 let triggered_manually = response_skeleton_opt. is_some ( ) ;
171- self . check_general_conditions_for_pending_payable_scan (
172- triggered_manually,
173- automatic_scans_enabled,
174- ) ?;
177+ if triggered_manually && automatic_scans_enabled {
178+ return Err ( StartScanError :: ManualTriggerError (
179+ ManulTriggerError :: AutomaticScanConflict ,
180+ ) ) ;
181+ }
182+
183+ self . check_pending_payable_existence ( triggered_manually) ?;
184+
175185 match (
176186 self . pending_payable . scan_started_at ( ) ,
177187 self . payable . scan_started_at ( ) ,
@@ -299,41 +309,14 @@ impl Scanners {
299309 self . initial_pending_payable_scan = false
300310 }
301311
302- // This is a helper function reducing a boilerplate of complex trait resolving where
303- // the compiler requires to specify which trigger message distinguishes the scan to run.
304- // The payable scanner offers two modes through doubled implementations of StartableScanner
305- // which uses the trigger message type as the only distinction between them.
306- fn start_correct_payable_scanner < ' a , TriggerMessage > (
307- scanner : & ' a mut ( dyn MultistageDualPayableScanner + ' a ) ,
308- wallet : & Wallet ,
309- timestamp : SystemTime ,
310- response_skeleton_opt : Option < ResponseSkeleton > ,
311- logger : & Logger ,
312- ) -> Result < InitialTemplatesMessage , StartScanError >
313- where
314- TriggerMessage : Message ,
315- ( dyn MultistageDualPayableScanner + ' a ) :
316- StartableScanner < TriggerMessage , InitialTemplatesMessage > ,
317- {
318- <( dyn MultistageDualPayableScanner + ' a ) as StartableScanner <
319- TriggerMessage ,
320- InitialTemplatesMessage ,
321- > >:: start_scan ( scanner, wallet, timestamp, response_skeleton_opt, logger)
322- }
323-
324- fn check_general_conditions_for_pending_payable_scan (
312+ fn check_pending_payable_existence (
325313 & mut self ,
326314 triggered_manually : bool ,
327- automatic_scans_enabled : bool ,
328315 ) -> Result < ( ) , StartScanError > {
329- if triggered_manually && automatic_scans_enabled {
330- return Err ( StartScanError :: ManualTriggerError (
331- ManulTriggerError :: AutomaticScanConflict ,
332- ) ) ;
333- }
334316 if self . initial_pending_payable_scan {
335317 return Ok ( ( ) ) ;
336318 }
319+
337320 if triggered_manually && !self . aware_of_unresolved_pending_payable {
338321 return Err ( StartScanError :: ManualTriggerError (
339322 ManulTriggerError :: UnnecessaryRequest {
@@ -1343,8 +1326,8 @@ mod tests {
13431326
13441327 #[ test]
13451328 #[ should_panic(
1346- expected = "internal error: entered unreachable code: Automatic pending payable \
1347- scan should never start if there are no pending payables to process."
1329+ expected = "internal error: entered unreachable code: Automatic pending payable scan should \
1330+ never start if there are no pending payables to process."
13481331 ) ]
13491332 fn pending_payable_scanner_bumps_into_zero_pending_payable_awareness_in_the_automatic_mode ( ) {
13501333 let consuming_wallet = make_paying_wallet ( b"consuming" ) ;
@@ -1363,11 +1346,12 @@ mod tests {
13631346 }
13641347
13651348 #[ test]
1366- fn check_general_conditions_for_pending_payable_scan_if_it_is_initial_pending_payable_scan ( ) {
1349+ fn check_pending_payable_existence_for_initial_pending_payable_scan_and_zero_awareness ( ) {
13671350 let mut subject = make_dull_subject ( ) ;
1351+ subject. aware_of_unresolved_pending_payable = false ;
13681352 subject. initial_pending_payable_scan = true ;
13691353
1370- let result = subject. check_general_conditions_for_pending_payable_scan ( false , true ) ;
1354+ let result = subject. check_pending_payable_existence ( false ) ;
13711355
13721356 assert_eq ! ( result, Ok ( ( ) ) ) ;
13731357 assert_eq ! ( subject. initial_pending_payable_scan, true ) ;
0 commit comments