prysm-pulse/beacon-chain/utils/slot_interval.go
2018-10-05 13:14:50 -04:00

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
}