-
Notifications
You must be signed in to change notification settings - Fork 995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Sync Checker #13580
Merged
Merged
Add Sync Checker #13580
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
617ed8e
fix it
nisdas 4845f3c
Merge branch 'develop' of https://github.com/prysmaticlabs/geth-shard…
nisdas 3109944
add it in
nisdas 6bd89e1
typo
nisdas 8767aa7
fix tests
nisdas 70188a1
fix tests
nisdas 08088c2
export and add test
nisdas 70a4c26
preston's review
nisdas 72b3edc
Merge branch 'develop' into addSyncChecker
nisdas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,28 @@ func WithVerifierWaiter(viw *verification.InitializerWaiter) Option { | |
} | ||
} | ||
|
||
// WithSyncChecker registers the initial sync service | ||
// in the checker. | ||
func WithSyncChecker(checker *SyncChecker) Option { | ||
return func(service *Service) { | ||
checker.Svc = service | ||
} | ||
} | ||
|
||
// SyncChecker allows other services to check the current status of | ||
// initial-sync and use that internally in their service. | ||
type SyncChecker struct { | ||
Svc *Service | ||
} | ||
|
||
// Synced returns the status of the service. | ||
func (s *SyncChecker) Synced() bool { | ||
if s.Svc == nil { | ||
return false | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a warning here? Seems like this should never be desired at runtime. |
||
return s.Svc.Synced() | ||
} | ||
|
||
// NewService configures the initial sync service responsible for bringing the node up to the | ||
// latest head of the blockchain. | ||
func NewService(ctx context.Context, cfg *Config, opts ...Option) *Service { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checker having the full service as a dependency doesn't look right to me... It seems like the initial sync service already implements the
SyncChecker
interface, you can use it as the blockchain's service dependency. One service depending on another is more natural.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason you cant do it is because initial sync has a dependency on the blockchain service. It is the reason the checker has been implemented