Skip to content

Commit 268eeba

Browse files
committed
GH-598: retry payable scan interval is half the duration of payable scan interval
1 parent af1a075 commit 268eeba

File tree

8 files changed

+10
-46
lines changed

8 files changed

+10
-46
lines changed

node/src/accountant/mod.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,6 @@ mod tests {
13191319
use crate::accountant::scanners::pending_payable_scanner::utils::TxByTable;
13201320
use crate::accountant::scanners::scan_schedulers::{
13211321
NewPayableScanIntervalComputer, NewPayableScanIntervalComputerReal, ScanTiming,
1322-
DEFAULT_RETRY_INTERVAL,
13231322
};
13241323
use crate::accountant::scanners::test_utils::{
13251324
MarkScanner, NewPayableScanIntervalComputerMock, PendingPayableCacheMock, ReplacementType,
@@ -1959,7 +1958,6 @@ mod tests {
19591958
let mut config = bc_from_earning_wallet(make_wallet("some_wallet_address"));
19601959
config.scan_intervals_opt = Some(ScanIntervals {
19611960
payable_scan_interval: Duration::from_millis(10_000),
1962-
retry_payable_scan_interval: Duration::from_millis(1),
19631961
receivable_scan_interval: Duration::from_millis(10_000),
19641962
pending_payable_scan_interval: Duration::from_secs(100),
19651963
});
@@ -2682,7 +2680,6 @@ mod tests {
26822680
let mut config = bc_from_earning_wallet(make_wallet("earning_wallet"));
26832681
config.scan_intervals_opt = Some(ScanIntervals {
26842682
payable_scan_interval: Duration::from_millis(10_000),
2685-
retry_payable_scan_interval: Duration::from_millis(1),
26862683
pending_payable_scan_interval: Duration::from_millis(2_000),
26872684
receivable_scan_interval: Duration::from_millis(10_000),
26882685
});
@@ -2731,7 +2728,6 @@ mod tests {
27312728
let mut config = bc_from_earning_wallet(make_wallet("earning_wallet"));
27322729
config.scan_intervals_opt = Some(ScanIntervals {
27332730
payable_scan_interval: Duration::from_millis(10_000),
2734-
retry_payable_scan_interval: Duration::from_millis(1),
27352731
pending_payable_scan_interval: Duration::from_millis(2_000),
27362732
receivable_scan_interval: Duration::from_millis(10_000),
27372733
});
@@ -3656,7 +3652,6 @@ mod tests {
36563652
let mut config = bc_from_earning_wallet(earning_wallet.clone());
36573653
config.scan_intervals_opt = Some(ScanIntervals {
36583654
payable_scan_interval: Duration::from_secs(100),
3659-
retry_payable_scan_interval: Duration::from_millis(1),
36603655
pending_payable_scan_interval: Duration::from_secs(10),
36613656
receivable_scan_interval: Duration::from_millis(99),
36623657
});
@@ -3936,7 +3931,6 @@ mod tests {
39363931
// This simply means that we're gonna surplus this value (it abides by how many pending
39373932
// payable cycles have to go in between before the lastly submitted txs are confirmed),
39383933
payable_scan_interval: Duration::from_millis(10),
3939-
retry_payable_scan_interval: Duration::from_millis(1),
39403934
pending_payable_scan_interval: Duration::from_millis(50),
39413935
receivable_scan_interval: Duration::from_secs(100), // We'll never run this scanner
39423936
});
@@ -4025,7 +4019,6 @@ mod tests {
40254019
let mut config = bc_from_earning_wallet(make_wallet("hi"));
40264020
config.scan_intervals_opt = Some(ScanIntervals {
40274021
payable_scan_interval: Duration::from_millis(100),
4028-
retry_payable_scan_interval: Duration::from_millis(1),
40294022
pending_payable_scan_interval: Duration::from_millis(50),
40304023
receivable_scan_interval: Duration::from_millis(100),
40314024
});
@@ -4148,7 +4141,6 @@ mod tests {
41484141
let consuming_wallet = make_paying_wallet(b"consuming");
41494142
config.scan_intervals_opt = Some(ScanIntervals {
41504143
payable_scan_interval: Duration::from_secs(50_000),
4151-
retry_payable_scan_interval: Duration::from_millis(1),
41524144
pending_payable_scan_interval: Duration::from_secs(10_000),
41534145
receivable_scan_interval: Duration::from_secs(50_000),
41544146
});
@@ -5249,7 +5241,7 @@ mod tests {
52495241
let mut payable_notify_params = retry_payable_notify_later_params_arc.lock().unwrap();
52505242
let (scheduled_msg, duration) = payable_notify_params.remove(0);
52515243
assert_eq!(scheduled_msg, ScanForRetryPayables::default());
5252-
assert_eq!(duration, DEFAULT_RETRY_INTERVAL);
5244+
assert_eq!(duration, Duration::from_secs(5 * 60));
52535245
assert!(
52545246
payable_notify_params.is_empty(),
52555247
"Should be empty but {:?}",
@@ -5314,7 +5306,7 @@ mod tests {
53145306
ScanForRetryPayables {
53155307
response_skeleton_opt: None
53165308
},
5317-
DEFAULT_RETRY_INTERVAL
5309+
Duration::from_secs(5 * 60)
53185310
)]
53195311
);
53205312
assert_using_the_same_logger(&logger, test_name, None)
@@ -5497,7 +5489,7 @@ mod tests {
54975489
ScanForRetryPayables {
54985490
response_skeleton_opt: Some(response_skeleton)
54995491
},
5500-
DEFAULT_RETRY_INTERVAL
5492+
Duration::from_secs(5 * 60)
55015493
)]
55025494
);
55035495
assert_using_the_same_logger(&logger, test_name, None)
@@ -5932,7 +5924,7 @@ mod tests {
59325924
ScanForRetryPayables {
59335925
response_skeleton_opt: None
59345926
},
5935-
DEFAULT_RETRY_INTERVAL
5927+
Duration::from_secs(5 * 60)
59365928
)]
59375929
)
59385930
}

node/src/accountant/scanners/scan_schedulers.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ use masq_lib::logger::Logger;
1414
use masq_lib::messages::ScanType;
1515
use masq_lib::simple_clock::{SimpleClock, SimpleClockReal};
1616
use std::fmt::{Debug, Display, Formatter};
17+
use std::ops::Div;
1718
use std::time::{Duration, SystemTime, UNIX_EPOCH};
1819

19-
pub const DEFAULT_RETRY_INTERVAL: Duration = Duration::from_secs(5 * 60);
20-
2120
pub struct ScanSchedulers {
2221
pub payable: PayableScanScheduler,
2322
pub pending_payable: SimplePeriodicalScanScheduler<ScanForPendingPayables>,
@@ -29,10 +28,7 @@ pub struct ScanSchedulers {
2928
impl ScanSchedulers {
3029
pub fn new(scan_intervals: ScanIntervals, automatic_scans_enabled: bool) -> Self {
3130
Self {
32-
payable: PayableScanScheduler::new(
33-
scan_intervals.payable_scan_interval,
34-
scan_intervals.retry_payable_scan_interval,
35-
),
31+
payable: PayableScanScheduler::new(scan_intervals.payable_scan_interval),
3632
pending_payable: SimplePeriodicalScanScheduler::new(
3733
scan_intervals.pending_payable_scan_interval,
3834
),
@@ -90,15 +86,15 @@ pub struct PayableScanScheduler {
9086
}
9187

9288
impl PayableScanScheduler {
93-
fn new(new_payable_interval: Duration, retry_payable_scan_interval: Duration) -> Self {
89+
fn new(payable_scan_interval: Duration) -> Self {
9490
Self {
9591
new_payable_notify_later: Box::new(NotifyLaterHandleReal::default()),
9692
interval_computer: Box::new(NewPayableScanIntervalComputerReal::new(
97-
new_payable_interval,
93+
payable_scan_interval,
9894
)),
9995
new_payable_notify: Box::new(NotifyHandleReal::default()),
10096
retry_payable_notify_later: Box::new(NotifyLaterHandleReal::default()),
101-
retry_payable_scan_interval,
97+
retry_payable_scan_interval: payable_scan_interval.div(2),
10298
}
10399
}
104100

@@ -394,7 +390,7 @@ impl RescheduleScanOnErrorResolverReal {
394390
mod tests {
395391
use crate::accountant::scanners::scan_schedulers::{
396392
NewPayableScanIntervalComputer, NewPayableScanIntervalComputerReal, PayableSequenceScanner,
397-
ScanReschedulingAfterEarlyStop, ScanSchedulers, ScanTiming, DEFAULT_RETRY_INTERVAL,
393+
ScanReschedulingAfterEarlyStop, ScanSchedulers, ScanTiming,
398394
};
399395
use crate::accountant::scanners::test_utils::NewPayableScanIntervalComputerMock;
400396
use crate::accountant::scanners::{ManulTriggerError, StartScanError};
@@ -411,16 +407,10 @@ mod tests {
411407
use std::sync::{Arc, Mutex};
412408
use std::time::{Duration, SystemTime, UNIX_EPOCH};
413409

414-
#[test]
415-
fn constants_have_correct_values() {
416-
assert_eq!(DEFAULT_RETRY_INTERVAL, Duration::from_secs(5 * 60));
417-
}
418-
419410
#[test]
420411
fn scan_schedulers_are_initialized_correctly() {
421412
let scan_intervals = ScanIntervals {
422413
payable_scan_interval: Duration::from_secs(14),
423-
retry_payable_scan_interval: Default::default(),
424414
pending_payable_scan_interval: Duration::from_secs(2),
425415
receivable_scan_interval: Duration::from_secs(7),
426416
};

node/src/db_config/persistent_configuration.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,6 @@ mod tests {
22912291
"60|5|50",
22922292
ScanIntervals {
22932293
payable_scan_interval: Duration::from_secs(60),
2294-
retry_payable_scan_interval: Duration::from_millis(1),
22952294
pending_payable_scan_interval: Duration::from_secs(5),
22962295
receivable_scan_interval: Duration::from_secs(50),
22972296
}

node/src/node_configurator/configurator.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,7 +2626,6 @@ mod tests {
26262626
}))
26272627
.scan_intervals_result(Ok(ScanIntervals {
26282628
payable_scan_interval: Duration::from_secs(125),
2629-
retry_payable_scan_interval: Duration::from_millis(1),
26302629
pending_payable_scan_interval: Duration::from_secs(122),
26312630
receivable_scan_interval: Duration::from_secs(128),
26322631
}))
@@ -2778,7 +2777,6 @@ mod tests {
27782777
}))
27792778
.scan_intervals_result(Ok(ScanIntervals {
27802779
payable_scan_interval: Default::default(),
2781-
retry_payable_scan_interval: Default::default(),
27822780
pending_payable_scan_interval: Default::default(),
27832781
receivable_scan_interval: Default::default(),
27842782
}))

node/src/node_configurator/unprivileged_parse_args_configuration.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,6 @@ mod tests {
18291829
configure_default_persistent_config(RATE_PACK | MAPPING_PROTOCOL)
18301830
.scan_intervals_result(Ok(ScanIntervals {
18311831
payable_scan_interval: Duration::from_secs(101),
1832-
retry_payable_scan_interval: Duration::from_millis(1),
18331832
pending_payable_scan_interval: Duration::from_secs(33),
18341833
receivable_scan_interval: Duration::from_secs(102),
18351834
}))
@@ -1858,7 +1857,6 @@ mod tests {
18581857

18591858
let expected_scan_intervals = ScanIntervals {
18601859
payable_scan_interval: Duration::from_secs(180),
1861-
retry_payable_scan_interval: Duration::from_millis(1),
18621860
pending_payable_scan_interval: Duration::from_secs(50),
18631861
receivable_scan_interval: Duration::from_secs(130),
18641862
};
@@ -1909,7 +1907,6 @@ mod tests {
19091907
configure_default_persistent_config(RATE_PACK | MAPPING_PROTOCOL)
19101908
.scan_intervals_result(Ok(ScanIntervals {
19111909
payable_scan_interval: Duration::from_secs(180),
1912-
retry_payable_scan_interval: Duration::from_millis(1),
19131910
pending_payable_scan_interval: Duration::from_secs(15),
19141911
receivable_scan_interval: Duration::from_secs(130),
19151912
}))
@@ -1942,7 +1939,6 @@ mod tests {
19421939
};
19431940
let expected_scan_intervals = ScanIntervals {
19441941
payable_scan_interval: Duration::from_secs(180),
1945-
retry_payable_scan_interval: Duration::from_millis(1),
19461942
pending_payable_scan_interval: Duration::from_secs(15),
19471943
receivable_scan_interval: Duration::from_secs(130),
19481944
};

node/src/sub_lib/accountant.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::accountant::db_access_objects::payable_dao::PayableDaoFactory;
55
use crate::accountant::db_access_objects::receivable_dao::ReceivableDaoFactory;
66
use crate::accountant::db_access_objects::sent_payable_dao::SentPayableDaoFactory;
77
use crate::accountant::scanners::payable_scanner::msgs::PricedTemplatesMessage;
8-
use crate::accountant::scanners::scan_schedulers::DEFAULT_RETRY_INTERVAL;
98
use crate::accountant::{
109
checked_conversion, Accountant, ReceivedPayments, ScanError, SentPayables, TxReceiptsMessage,
1110
};
@@ -78,7 +77,6 @@ pub struct DaoFactories {
7877
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
7978
pub struct ScanIntervals {
8079
pub payable_scan_interval: Duration,
81-
pub retry_payable_scan_interval: Duration,
8280
pub pending_payable_scan_interval: Duration,
8381
pub receivable_scan_interval: Duration,
8482
}
@@ -87,7 +85,6 @@ impl ScanIntervals {
8785
pub fn compute_default(chain: Chain) -> Self {
8886
Self {
8987
payable_scan_interval: Duration::from_secs(600),
90-
retry_payable_scan_interval: DEFAULT_RETRY_INTERVAL,
9188
pending_payable_scan_interval: Duration::from_secs(
9289
chain.rec().default_pending_payable_interval_sec,
9390
),
@@ -207,7 +204,6 @@ pub enum DetailedScanType {
207204

208205
#[cfg(test)]
209206
mod tests {
210-
use crate::accountant::scanners::scan_schedulers::DEFAULT_RETRY_INTERVAL;
211207
use crate::accountant::test_utils::AccountantBuilder;
212208
use crate::accountant::{checked_conversion, Accountant};
213209
use crate::sub_lib::accountant::{
@@ -323,7 +319,6 @@ mod tests {
323319
result_a,
324320
ScanIntervals {
325321
payable_scan_interval: Duration::from_secs(600),
326-
retry_payable_scan_interval: DEFAULT_RETRY_INTERVAL,
327322
pending_payable_scan_interval: Duration::from_secs(
328323
chain_a.rec().default_pending_payable_interval_sec
329324
),
@@ -334,7 +329,6 @@ mod tests {
334329
result_b,
335330
ScanIntervals {
336331
payable_scan_interval: Duration::from_secs(600),
337-
retry_payable_scan_interval: DEFAULT_RETRY_INTERVAL,
338332
pending_payable_scan_interval: Duration::from_secs(
339333
chain_b.rec().default_pending_payable_interval_sec
340334
),

node/src/sub_lib/combined_parameters.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ impl CombinedParams {
178178
&parsed_values,
179179
Duration::from_secs,
180180
"payable_scan_interval",
181-
"retry_payable_scan_interval",
182181
"pending_payable_scan_interval",
183182
"receivable_scan_interval"
184183
)))
@@ -306,7 +305,6 @@ fn unreachable() -> ! {
306305
#[cfg(test)]
307306
mod tests {
308307
use super::*;
309-
use crate::accountant::scanners::scan_schedulers::DEFAULT_RETRY_INTERVAL;
310308
use crate::sub_lib::combined_parameters::CombinedParamsDataTypes::U128;
311309
use crate::sub_lib::neighborhood::DEFAULT_RATE_PACK;
312310
use crate::test_utils::unshared_test_utils::TEST_SCAN_INTERVALS;
@@ -561,7 +559,6 @@ mod tests {
561559
result,
562560
ScanIntervals {
563561
payable_scan_interval: Duration::from_secs(115),
564-
retry_payable_scan_interval: DEFAULT_RETRY_INTERVAL,
565562
pending_payable_scan_interval: Duration::from_secs(55),
566563
receivable_scan_interval: Duration::from_secs(113)
567564
}
@@ -572,7 +569,6 @@ mod tests {
572569
fn scan_intervals_to_combined_params() {
573570
let scan_intervals = ScanIntervals {
574571
payable_scan_interval: Duration::from_secs(90),
575-
retry_payable_scan_interval: DEFAULT_RETRY_INTERVAL,
576572
pending_payable_scan_interval: Duration::from_secs(40),
577573
receivable_scan_interval: Duration::from_secs(100),
578574
};

node/src/test_utils/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ pub mod unshared_test_utils {
627627
lazy_static! {
628628
pub static ref TEST_SCAN_INTERVALS: ScanIntervals = ScanIntervals {
629629
payable_scan_interval: Duration::from_secs(600),
630-
retry_payable_scan_interval: Duration::from_millis(1),
631630
pending_payable_scan_interval: Duration::from_secs(360),
632631
receivable_scan_interval: Duration::from_secs(600),
633632
};

0 commit comments

Comments
 (0)