@@ -11,6 +11,7 @@ use futures::channel::{mpsc, oneshot};
1111use futures:: stream:: FuturesOrdered ;
1212use futures:: { select, FutureExt , SinkExt , StreamExt } ;
1313use parity_scale_codec:: Encode ;
14+ use rand:: prelude:: * ;
1415use std:: collections:: HashSet ;
1516use std:: future:: Future ;
1617use std:: io;
@@ -700,8 +701,8 @@ pub(super) struct PlottingSchedulerOptions<NC> {
700701 pub ( super ) handlers : Arc < Handlers > ,
701702 pub ( super ) sectors_metadata : Arc < AsyncRwLock < Vec < SectorMetadataChecksummed > > > ,
702703 pub ( super ) sectors_to_plot_sender : mpsc:: Sender < SectorToPlot > ,
703- // Delay between segment header being acknowledged by farmer and potentially triggering
704- // replotting
704+ // Max delay between segment header being acknowledged by farmer and potentially
705+ // triggering replotting
705706 pub ( super ) new_segment_processing_delay : Duration ,
706707 pub ( super ) metrics : Option < Arc < SingleDiskFarmMetrics > > ,
707708}
@@ -798,7 +799,10 @@ where
798799
799800 // There is no urgent need to rush replotting sectors immediately and this delay allows for
800801 // newly archived pieces to be both cached locally and on other farmers on the network
801- tokio:: time:: sleep ( new_segment_processing_delay) . await ;
802+ let delay = Duration :: from_secs ( thread_rng ( ) . gen_range (
803+ new_segment_processing_delay. as_secs ( ) / 10 ..=new_segment_processing_delay. as_secs ( ) ,
804+ ) ) ;
805+ tokio:: time:: sleep ( delay) . await ;
802806
803807 if archived_segments_sender. send ( segment_header) . is_err ( ) {
804808 break ;
0 commit comments