Commit 8988a460 authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

l2geth: cleanup `time.Ticker`s in `SyncService`

Simply clean up the `time.Ticker`s using `defer t.Close()`.
Not having this code should not cause any problems, but
it is best practice to close the tickers as not doing so
can result in memory leaks in certain cases.
parent 5c0e90aa
---
'@eth-optimism/l2geth': patch
---
Cleanup `time.Ticker`s
...@@ -359,6 +359,7 @@ func (s *SyncService) Stop() error { ...@@ -359,6 +359,7 @@ func (s *SyncService) Stop() error {
func (s *SyncService) VerifierLoop() { 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()
for ; true; <-t.C { for ; true; <-t.C {
if err := s.verify(); err != nil { if err := s.verify(); err != nil {
log.Error("Could not verify", "error", err) log.Error("Could not verify", "error", err)
...@@ -387,6 +388,7 @@ func (s *SyncService) verify() error { ...@@ -387,6 +388,7 @@ func (s *SyncService) verify() error {
func (s *SyncService) SequencerLoop() { func (s *SyncService) SequencerLoop() {
log.Info("Starting Sequencer Loop", "poll-interval", s.pollInterval, "timestamp-refresh-threshold", s.timestampRefreshThreshold) log.Info("Starting Sequencer Loop", "poll-interval", s.pollInterval, "timestamp-refresh-threshold", s.timestampRefreshThreshold)
t := time.NewTicker(s.pollInterval) t := time.NewTicker(s.pollInterval)
defer t.Stop()
for ; true; <-t.C { for ; true; <-t.C {
s.txLock.Lock() s.txLock.Lock()
if err := s.sequence(); err != nil { if err := s.sequence(); err != nil {
......
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