mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 23:48:06 -05:00
Cancel Initial Sync Properly (#5529)
* fix cancelling * Merge branch 'master' into cancelServices * Merge refs/heads/master into cancelServices * Merge refs/heads/master into cancelServices
This commit is contained in:
@@ -47,6 +47,7 @@ type Config struct {
|
||||
// Service service.
|
||||
type Service struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
chain blockchainService
|
||||
p2p p2p.P2P
|
||||
db db.ReadOnlyDatabase
|
||||
@@ -60,8 +61,10 @@ type Service struct {
|
||||
// NewInitialSync configures the initial sync service responsible for bringing the node up to the
|
||||
// latest head of the blockchain.
|
||||
func NewInitialSync(cfg *Config) *Service {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
return &Service{
|
||||
ctx: context.Background(),
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
chain: cfg.Chain,
|
||||
p2p: cfg.P2P,
|
||||
db: cfg.DB,
|
||||
@@ -157,6 +160,7 @@ func (s *Service) Start() {
|
||||
|
||||
// Stop initial sync.
|
||||
func (s *Service) Stop() error {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user