mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-14 00:29:04 +00:00
optimize LC sync task scheduling (#5112)
- When syncing `LightClientUpdatesByRange`, and peer replies with fewer periods than requested, no need to delay next request. - When `FinalityUpdate` / `OptimisticUpdate` sync fails, no need to retry immediately.
This commit is contained in:
parent
6175fa8a79
commit
bab6a77abc
@ -341,6 +341,7 @@ template query[E](
|
||||
self.query(e, Nothing())
|
||||
|
||||
type SchedulingMode = enum
|
||||
Now,
|
||||
Soon,
|
||||
CurrentPeriod,
|
||||
NextPeriod
|
||||
@ -353,6 +354,8 @@ func fetchTime(
|
||||
let
|
||||
remainingTime =
|
||||
case schedulingMode:
|
||||
of Now:
|
||||
return wallTime
|
||||
of Soon:
|
||||
chronos.seconds(0)
|
||||
of CurrentPeriod:
|
||||
@ -413,9 +416,12 @@ proc loop(self: LightClientManager) {.async.} =
|
||||
await self.query(OptimisticUpdate)
|
||||
|
||||
schedulingMode =
|
||||
if not didProgress or not self.isGossipSupported(current):
|
||||
Soon
|
||||
elif syncTask.kind != LcSyncKind.OptimisticUpdate:
|
||||
if not self.isGossipSupported(current):
|
||||
if didProgress:
|
||||
Now
|
||||
else:
|
||||
Soon
|
||||
elif self.getFinalizedPeriod() != self.getOptimisticPeriod():
|
||||
CurrentPeriod
|
||||
else:
|
||||
NextPeriod
|
||||
|
Loading…
x
Reference in New Issue
Block a user