Commit 0e8652c2 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

l2geth: cleanly shut down the syncservice (#4129)

The ss was not previously being shut down cleanly, which
can result in a corrupted db state. This makes the shutdown
more clean.
parent 5acb97e0
---
'@eth-optimism/l2geth': patch
---
Close down the syncservice more cleanly
...@@ -403,6 +403,7 @@ func (s *SyncService) IsSyncing() bool { ...@@ -403,6 +403,7 @@ func (s *SyncService) IsSyncing() bool {
// Stop will close the open channels and cancel the goroutines // Stop will close the open channels and cancel the goroutines
// started by this service. // started by this service.
func (s *SyncService) Stop() error { func (s *SyncService) Stop() error {
log.Info("Stopping sync service")
s.scope.Close() s.scope.Close()
s.chainHeadSub.Unsubscribe() s.chainHeadSub.Unsubscribe()
close(s.chainHeadCh) close(s.chainHeadCh)
...@@ -418,9 +419,15 @@ func (s *SyncService) VerifierLoop() { ...@@ -418,9 +419,15 @@ func (s *SyncService) VerifierLoop() {
log.Info("Starting Verifier Loop", "poll-interval", s.pollInterval, "timestamp-refresh-threshold", s.timestampRefreshThreshold) log.Info("Starting Verifier Loop", "poll-interval", s.pollInterval, "timestamp-refresh-threshold", s.timestampRefreshThreshold)
t := time.NewTicker(s.pollInterval) t := time.NewTicker(s.pollInterval)
defer t.Stop() defer t.Stop()
for ; true; <-t.C {
if err := s.verify(); err != nil { for {
log.Error("Could not verify", "error", err) select {
case <-t.C:
if err := s.verify(); err != nil {
log.Error("Could not verify", "error", err)
}
case <-s.ctx.Done():
return
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment