File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
code/go/0chain.net/blobbercore/writemarker Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -256,7 +256,8 @@ func retryRedeem(errString string) bool {
256
256
}
257
257
258
258
func startCollector (ctx context.Context ) {
259
- ticker := time .NewTicker (config .Configuration .MarkerRedeemInterval )
259
+ randTime := getRandTime ()
260
+ ticker := time .NewTicker (time .Duration (randTime ) * time .Second )
260
261
defer ticker .Stop ()
261
262
for {
262
263
select {
@@ -272,6 +273,8 @@ func startCollector(ctx context.Context) {
272
273
}
273
274
}
274
275
markerDataMut .Unlock ()
276
+ randTime = getRandTime ()
277
+ ticker .Reset (time .Duration (randTime ) * time .Second )
275
278
}
276
279
}
277
280
}
@@ -284,6 +287,13 @@ func (md *markerData) processMarker() bool {
284
287
return ! md .processing && ! md .inCommit && (md .chainLength >= config .Configuration .MaxChainLength || common .Now ()- md .firstMarkerTimestamp > common .Timestamp (config .Configuration .MaxTimestampGap ) || common .Now ()- md .lastMarkerTimestamp > common .Timestamp (randTime ))
285
288
}
286
289
290
+ func getRandTime () int64 {
291
+ secondsInterval := int64 (config .Configuration .MarkerRedeemInterval .Seconds ())
292
+ randTime := rand .Int63n (secondsInterval / 2 )
293
+ randTime += secondsInterval / 2 // interval of secondsInterval/2 to secondsInterval
294
+ return randTime
295
+ }
296
+
287
297
// TODO: don't delete prev WM
288
298
// func startCleanupWorker(ctx context.Context) {
289
299
// for {
You can’t perform that action at this time.
0 commit comments