Update parameter names; add fallback connection.

Update parameter names to meet newer standards.

Provide a fallback beacon node if none other supplied.
This commit is contained in:
Jim McDonald
2023-04-09 23:19:19 +01:00
parent df99d43415
commit 2c01d18195
58 changed files with 491 additions and 521 deletions

View File

@@ -46,6 +46,8 @@ type Service interface {
SlotToSyncCommitteePeriod(slot phase0.Slot) uint64
// FirstSlotOfEpoch provides the first slot of the given epoch.
FirstSlotOfEpoch(epoch phase0.Epoch) phase0.Slot
// LastSlotOfEpoch provides the last slot of the given epoch.
LastSlotOfEpoch(epoch phase0.Epoch) phase0.Slot
// TimestampToSlot provides the slot of the given timestamp.
TimestampToSlot(timestamp time.Time) phase0.Slot
// TimestampToEpoch provides the epoch of the given timestamp.

View File

@@ -178,6 +178,11 @@ func (s *Service) FirstSlotOfEpoch(epoch phase0.Epoch) phase0.Slot {
return phase0.Slot(uint64(epoch) * s.slotsPerEpoch)
}
// LastSlotOfEpoch provides the last slot of the given epoch.
func (s *Service) LastSlotOfEpoch(epoch phase0.Epoch) phase0.Slot {
return phase0.Slot(uint64(epoch)*s.slotsPerEpoch + s.slotsPerEpoch - 1)
}
// TimestampToSlot provides the slot of the given timestamp.
func (s *Service) TimestampToSlot(timestamp time.Time) phase0.Slot {
if timestamp.Before(s.genesisTime) {