mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 17:44:29 +00:00
3f1d5a4c92
* added proper chain config * updated configs * save progress * fix lint Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
24 lines
512 B
Go
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
|
|
}
|