@@ -105,6 +105,9 @@ const DEFAULT_EPOCH_DURATION: Duration =
105
105
Duration :: from_millis ( DEFAULT_SLOTS_PER_EPOCH * DEFAULT_MS_PER_SLOT ) ;
106
106
/// milliseconds we sleep for between gossip requests
107
107
pub const GOSSIP_SLEEP_MILLIS : u64 = 100 ;
108
+ /// Interval between pull requests
109
+ const PULL_REQUEST_INTERVAL : Duration = Duration :: from_millis ( 500 ) ;
110
+
108
111
/// Capacity for the [`ClusterInfo::run_socket_consume`] and [`ClusterInfo::run_listen`]
109
112
/// intermediate packet batch buffers.
110
113
///
@@ -1468,7 +1471,7 @@ impl ClusterInfo {
1468
1471
let mut last_contact_info_save = timestamp ( ) ;
1469
1472
let mut entrypoints_processed = false ;
1470
1473
let recycler = PacketBatchRecycler :: default ( ) ;
1471
- let mut generate_pull_requests = true ;
1474
+ let mut last_pull_request = Instant :: now ( ) ;
1472
1475
while !exit. load ( Ordering :: Relaxed ) {
1473
1476
let start = timestamp ( ) ;
1474
1477
if self . contact_debug_interval != 0
@@ -1494,6 +1497,11 @@ impl ClusterInfo {
1494
1497
. map ( EpochSpecs :: current_epoch_staked_nodes)
1495
1498
. cloned ( )
1496
1499
. unwrap_or_default ( ) ;
1500
+ let generate_pull_requests =
1501
+ last_pull_request. elapsed ( ) > PULL_REQUEST_INTERVAL ;
1502
+ if generate_pull_requests {
1503
+ last_pull_request = Instant :: now ( ) ;
1504
+ }
1497
1505
let _ = self . run_gossip (
1498
1506
& thread_pool,
1499
1507
gossip_validators. as_ref ( ) ,
@@ -1525,7 +1533,6 @@ impl ClusterInfo {
1525
1533
let time_left = GOSSIP_SLEEP_MILLIS - elapsed;
1526
1534
sleep ( Duration :: from_millis ( time_left) ) ;
1527
1535
}
1528
- generate_pull_requests = !generate_pull_requests;
1529
1536
}
1530
1537
} )
1531
1538
. unwrap ( )
0 commit comments