mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
03356fc7b5
* add resyncing functionality * add more validation to status message * lint and build * jim's review * preston's review * clean up * remove log * remove no sync * change again * change back * remove spaces * Update shared/slotutil/slottime.go Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com> * Apply suggestions from code review Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com> * fix refs * raul's review * goimports * goimports * add counter * removed condition * change back * gaz Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
29 lines
879 B
Go
29 lines
879 B
Go
package slotutil
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
"github.com/prysmaticlabs/prysm/shared/roughtime"
|
|
)
|
|
|
|
// SlotStartTime returns the start time in terms of its unix epoch
|
|
// value.
|
|
func SlotStartTime(genesis uint64, slot uint64) time.Time {
|
|
duration := time.Second * time.Duration(slot*params.BeaconConfig().SecondsPerSlot)
|
|
startTime := time.Unix(int64(genesis), 0).Add(duration)
|
|
return startTime
|
|
}
|
|
|
|
// SlotsSinceGenesis returns the number of slots since
|
|
// the provided genesis time.
|
|
func SlotsSinceGenesis(genesis time.Time) uint64 {
|
|
return uint64(roughtime.Since(genesis).Seconds()) / params.BeaconConfig().SecondsPerSlot
|
|
}
|
|
|
|
// EpochsSinceGenesis returns the number of slots since
|
|
// the provided genesis time.
|
|
func EpochsSinceGenesis(genesis time.Time) uint64 {
|
|
return SlotsSinceGenesis(genesis) / params.BeaconConfig().SlotsPerEpoch
|
|
}
|