@@ -111,11 +111,6 @@ const SCORER_PERSIST_TIMER: u64 = 30;
111
111
#[ cfg( test) ]
112
112
const SCORER_PERSIST_TIMER : u64 = 1 ;
113
113
114
- #[ cfg( not( test) ) ]
115
- const FIRST_NETWORK_PRUNE_TIMER : u64 = 60 ;
116
- #[ cfg( test) ]
117
- const FIRST_NETWORK_PRUNE_TIMER : u64 = 1 ;
118
-
119
114
#[ cfg( not( test) ) ]
120
115
const REBROADCAST_TIMER : u64 = 30 ;
121
116
#[ cfg( test) ]
@@ -126,7 +121,7 @@ const REBROADCAST_TIMER: u64 = 1;
126
121
const fn min_u64 ( a : u64 , b : u64 ) -> u64 { if a < b { a } else { b } }
127
122
#[ cfg( feature = "futures" ) ]
128
123
const FASTEST_TIMER : u64 = min_u64 ( min_u64 ( FRESHNESS_TIMER , PING_TIMER ) ,
129
- min_u64 ( SCORER_PERSIST_TIMER , min_u64 ( FIRST_NETWORK_PRUNE_TIMER , REBROADCAST_TIMER ) ) ) ;
124
+ min_u64 ( SCORER_PERSIST_TIMER , REBROADCAST_TIMER ) ) ;
130
125
131
126
/// Either [`P2PGossipSync`] or [`RapidGossipSync`].
132
127
pub enum GossipSync <
@@ -275,7 +270,7 @@ macro_rules! define_run_body {
275
270
276
271
let mut last_freshness_call = $get_timer( FRESHNESS_TIMER ) ;
277
272
let mut last_ping_call = $get_timer( PING_TIMER ) ;
278
- let mut last_prune_call = $get_timer( FIRST_NETWORK_PRUNE_TIMER ) ;
273
+ let mut last_prune_call = $get_timer( NETWORK_PRUNE_TIMER ) ;
279
274
let mut last_scorer_persist_call = $get_timer( SCORER_PERSIST_TIMER ) ;
280
275
let mut last_rebroadcast_call = $get_timer( REBROADCAST_TIMER ) ;
281
276
let mut have_pruned = false ;
@@ -352,8 +347,7 @@ macro_rules! define_run_body {
352
347
// falling back to our usual hourly prunes. This avoids short-lived clients never
353
348
// pruning their network graph. We run once 60 seconds after startup before
354
349
// continuing our normal cadence.
355
- let prune_timer = if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER } ;
356
- if $timer_elapsed( & mut last_prune_call, prune_timer) {
350
+ if !have_pruned || $timer_elapsed( & mut last_prune_call, NETWORK_PRUNE_TIMER ) {
357
351
// The network graph must not be pruned while rapid sync completion is pending
358
352
if let Some ( network_graph) = $gossip_sync. prunable_network_graph( ) {
359
353
#[ cfg( feature = "std" ) ] {
@@ -371,8 +365,7 @@ macro_rules! define_run_body {
371
365
372
366
have_pruned = true ;
373
367
}
374
- let prune_timer = if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER } ;
375
- last_prune_call = $get_timer( prune_timer) ;
368
+ last_prune_call = $get_timer( NETWORK_PRUNE_TIMER ) ;
376
369
}
377
370
378
371
if $timer_elapsed( & mut last_scorer_persist_call, SCORER_PERSIST_TIMER ) {
@@ -1557,7 +1550,7 @@ mod tests {
1557
1550
let background_processor = BackgroundProcessor :: start ( persister, event_handler, nodes[ 0 ] . chain_monitor . clone ( ) , nodes[ 0 ] . node . clone ( ) , nodes[ 0 ] . rapid_gossip_sync ( ) , nodes[ 0 ] . peer_manager . clone ( ) , nodes[ 0 ] . logger . clone ( ) , Some ( nodes[ 0 ] . scorer . clone ( ) ) ) ;
1558
1551
1559
1552
do_test_not_pruning_network_graph_until_graph_sync_completion ! ( nodes,
1560
- receiver. recv_timeout( Duration :: from_secs( super :: FIRST_NETWORK_PRUNE_TIMER * 5 ) ) ,
1553
+ receiver. recv_timeout( Duration :: from_secs( 5 ) ) ,
1561
1554
std:: thread:: sleep( Duration :: from_millis( 1 ) ) ) ;
1562
1555
1563
1556
background_processor. stop ( ) . unwrap ( ) ;
@@ -1592,7 +1585,7 @@ mod tests {
1592
1585
do_test_not_pruning_network_graph_until_graph_sync_completion ! ( nodes, {
1593
1586
let mut i = 0 ;
1594
1587
loop {
1595
- tokio:: time:: sleep( Duration :: from_secs( super :: FIRST_NETWORK_PRUNE_TIMER ) ) . await ;
1588
+ tokio:: time:: sleep( Duration :: from_secs( 1 ) ) . await ;
1596
1589
if let Ok ( ( ) ) = receiver. try_recv( ) { break Ok :: <( ) , ( ) >( ( ) ) ; }
1597
1590
assert!( i < 5 ) ;
1598
1591
i += 1 ;
0 commit comments