mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Do not downcast time in currentslot (#10897)
* Do not downcast time in currentslot * no magic constants Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -164,12 +164,11 @@ func Since(time time.Time) types.Slot {
|
||||
// CurrentSlot returns the current slot as determined by the local clock and
|
||||
// provided genesis time.
|
||||
func CurrentSlot(genesisTimeSec uint64) types.Slot {
|
||||
now := prysmTime.Now().Unix()
|
||||
genesis := int64(genesisTimeSec) // lint:ignore uintcast -- Genesis timestamp will not exceed int64 in your lifetime.
|
||||
if now < genesis {
|
||||
now := uint64(prysmTime.Now().Unix())
|
||||
if now < genesisTimeSec {
|
||||
return 0
|
||||
}
|
||||
return types.Slot(uint64(now-genesis) / params.BeaconConfig().SecondsPerSlot)
|
||||
return types.Slot((now - genesisTimeSec) / params.BeaconConfig().SecondsPerSlot)
|
||||
}
|
||||
|
||||
// ValidateClock validates a provided slot against the local
|
||||
|
||||
Reference in New Issue
Block a user