prysm-pulse/beacon-chain/utils/slot_interval.go

18 lines
404 B
Go
Raw Normal View History

2018-10-05 17:14:50 +00:00
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
}