mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Add aggregation metrics (#12417)
This commit is contained in:
@@ -252,3 +252,9 @@ func SecondsSinceSlotStart(s primitives.Slot, genesisTime, timeStamp uint64) (ui
|
||||
}
|
||||
return timeStamp - genesisTime - uint64(s)*params.BeaconConfig().SecondsPerSlot, nil
|
||||
}
|
||||
|
||||
// TimeIntoSlot returns the time duration elapsed between the current time and
|
||||
// the start of the current slot
|
||||
func TimeIntoSlot(genesisTime uint64) time.Duration {
|
||||
return time.Since(StartTime(genesisTime, CurrentSlot(genesisTime)))
|
||||
}
|
||||
|
||||
@@ -563,3 +563,9 @@ func TestDuration(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTimeIntoSlot(t *testing.T) {
|
||||
genesisTime := uint64(time.Now().Add(-37 * time.Second).Unix())
|
||||
require.Equal(t, true, TimeIntoSlot(genesisTime) > 900*time.Millisecond)
|
||||
require.Equal(t, true, TimeIntoSlot(genesisTime) < 3000*time.Millisecond)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user