erigon-pulse/cmd/lightclient/utils/time.go
Giulio rebuffo 3f1d5a4c92
Support for Goerli/Sepolia/Mainnet Fork ids on Consensus Layer (#5575)
* added proper chain config

* updated configs

* save progress

* fix lint

Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
2022-09-30 00:20:09 +02:00

24 lines
512 B
Go

package utils
import "time"
// compute current slot.
func GetCurrentSlot(genesisTime uint64, secondsPerSlot uint64) uint64 {
now := uint64(time.Now().Unix())
if now < genesisTime {
return 0
}
return (now - genesisTime) / secondsPerSlot
}
// compute current epoch.
func GetCurrentEpoch(genesisTime uint64, secondsPerSlot uint64, slotsPerEpoch uint64) uint64 {
now := uint64(time.Now().Unix())
if now < genesisTime {
return 0
}
return GetCurrentSlot(genesisTime, secondsPerSlot) / slotsPerEpoch
}