simplify `computeEarliestLightClientSlot` (#3524)

Combine DAG and LC import tails in `computeEarliestLightClientSlot`.
This commit is contained in:
Etan Kissling 2022-03-19 09:58:55 +01:00 committed by GitHub
parent ea5c052016
commit 637f1e2be6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -52,12 +52,11 @@ func computeEarliestLightClientSlot*(dag: ChainDAGRef): Slot =
dag.cfg.CHURN_LIMIT_QUOTIENT div 2
MIN_SLOTS_FOR_BLOCK_REQUESTS =
MIN_EPOCHS_FOR_BLOCK_REQUESTS * SLOTS_PER_EPOCH
minSlot = max(minSupportedSlot, dag.tail.slot)
if currentSlot - minSlot < MIN_SLOTS_FOR_BLOCK_REQUESTS:
return minSlot
if currentSlot - minSupportedSlot < MIN_SLOTS_FOR_BLOCK_REQUESTS:
return minSupportedSlot
let earliestSlot = currentSlot - MIN_SLOTS_FOR_BLOCK_REQUESTS
max(earliestSlot.sync_committee_period.start_slot, minSlot)
max(earliestSlot.sync_committee_period.start_slot, minSupportedSlot)
proc currentSyncCommitteeForPeriod(
dag: ChainDAGRef,
@ -730,6 +729,7 @@ proc initLightClientCache*(dag: ChainDAGRef) =
if dag.importLightClientData == ImportLightClientData.OnlyNew:
dag.lightClientCache.importTailSlot = dag.head.slot + 1
return
dag.lightClientCache.importTailSlot = dag.tail.slot
let earliestSlot = dag.computeEarliestLightClientSlot
if dag.head.slot < earliestSlot:
return