mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-19 17:58:23 +00:00
simplify computeEarliestLightClientSlot
(#3524)
Combine DAG and LC import tails in `computeEarliestLightClientSlot`.
This commit is contained in:
parent
ea5c052016
commit
637f1e2be6
@ -52,12 +52,11 @@ func computeEarliestLightClientSlot*(dag: ChainDAGRef): Slot =
|
|||||||
dag.cfg.CHURN_LIMIT_QUOTIENT div 2
|
dag.cfg.CHURN_LIMIT_QUOTIENT div 2
|
||||||
MIN_SLOTS_FOR_BLOCK_REQUESTS =
|
MIN_SLOTS_FOR_BLOCK_REQUESTS =
|
||||||
MIN_EPOCHS_FOR_BLOCK_REQUESTS * SLOTS_PER_EPOCH
|
MIN_EPOCHS_FOR_BLOCK_REQUESTS * SLOTS_PER_EPOCH
|
||||||
minSlot = max(minSupportedSlot, dag.tail.slot)
|
if currentSlot - minSupportedSlot < MIN_SLOTS_FOR_BLOCK_REQUESTS:
|
||||||
if currentSlot - minSlot < MIN_SLOTS_FOR_BLOCK_REQUESTS:
|
return minSupportedSlot
|
||||||
return minSlot
|
|
||||||
|
|
||||||
let earliestSlot = currentSlot - MIN_SLOTS_FOR_BLOCK_REQUESTS
|
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(
|
proc currentSyncCommitteeForPeriod(
|
||||||
dag: ChainDAGRef,
|
dag: ChainDAGRef,
|
||||||
@ -730,6 +729,7 @@ proc initLightClientCache*(dag: ChainDAGRef) =
|
|||||||
if dag.importLightClientData == ImportLightClientData.OnlyNew:
|
if dag.importLightClientData == ImportLightClientData.OnlyNew:
|
||||||
dag.lightClientCache.importTailSlot = dag.head.slot + 1
|
dag.lightClientCache.importTailSlot = dag.head.slot + 1
|
||||||
return
|
return
|
||||||
|
dag.lightClientCache.importTailSlot = dag.tail.slot
|
||||||
let earliestSlot = dag.computeEarliestLightClientSlot
|
let earliestSlot = dag.computeEarliestLightClientSlot
|
||||||
if dag.head.slot < earliestSlot:
|
if dag.head.slot < earliestSlot:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user