Refactor: move functions beacon-chain/core/time -> time/slots (#9719)

* Move necessary functions beacon-chain/core/time -> time/slots

* Fix fuzz

* Fix build

* Update slot_epoch.go
This commit is contained in:
terence tsao
2021-10-01 13:17:57 -07:00
committed by GitHub
parent 4f31ba6489
commit c21e43e4c5
163 changed files with 739 additions and 720 deletions

View File

@@ -14,13 +14,13 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
blockfeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/block"
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
coreTime "github.com/prysmaticlabs/prysm/beacon-chain/core/time"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
"github.com/prysmaticlabs/prysm/config/params"
"github.com/prysmaticlabs/prysm/runtime"
prysmTime "github.com/prysmaticlabs/prysm/time"
"github.com/prysmaticlabs/prysm/time/slots"
"github.com/sirupsen/logrus"
)
@@ -87,8 +87,8 @@ func (s *Service) Start() {
log.WithField("genesisTime", genesis).Info("Genesis time has not arrived - not syncing")
return
}
currentSlot := coreTime.SlotsSince(genesis)
if coreTime.SlotToEpoch(currentSlot) == 0 {
currentSlot := slots.Since(genesis)
if slots.ToEpoch(currentSlot) == 0 {
log.WithField("genesisTime", genesis).Info("Chain started within the last epoch - not syncing")
s.markSynced(genesis)
return
@@ -96,7 +96,7 @@ func (s *Service) Start() {
s.chainStarted.Set()
log.Info("Starting initial chain sync...")
// Are we already in sync, or close to it?
if coreTime.SlotToEpoch(s.cfg.Chain.HeadSlot()) == coreTime.SlotToEpoch(currentSlot) {
if slots.ToEpoch(s.cfg.Chain.HeadSlot()) == slots.ToEpoch(currentSlot) {
log.Info("Already synced to the current chain head")
s.markSynced(genesis)
return