Check if initial sync service has been initialized (#8214)

This commit is contained in:
Radosław Kapka
2021-01-06 11:45:22 +01:00
committed by GitHub
parent c354871762
commit 7135a8542f
2 changed files with 17 additions and 2 deletions

View File

@@ -127,7 +127,7 @@ func (s *Service) Stop() error {
// Status of initial sync.
func (s *Service) Status() error {
if s.synced.IsNotSet() && s.chainStarted.IsSet() {
if s.Syncing() {
return errors.New("syncing")
}
return nil
@@ -138,6 +138,11 @@ func (s *Service) Syncing() bool {
return s.synced.IsNotSet()
}
// Initialized returns true if initial sync has been started.
func (s *Service) Initialized() bool {
return s.chainStarted.IsSet()
}
// Resync allows a node to start syncing again if it has fallen
// behind the current network head.
func (s *Service) Resync() error {