mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
18 lines
404 B
Go
18 lines
404 B
Go
package utils
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/params"
|
|
)
|
|
|
|
// CurrentSlot returns slot number based on the genesis timestamp.
|
|
func CurrentSlot(genesisTime time.Time) uint64 {
|
|
secondsSinceGenesis := uint64(time.Since(genesisTime).Seconds())
|
|
currentSlot := secondsSinceGenesis / params.GetConfig().SlotDuration
|
|
if currentSlot < 1 {
|
|
return 0
|
|
}
|
|
return currentSlot - 1
|
|
}
|