Skip to content

Commit

Permalink
Merge pull request #26 from libsv/fix-ticker-memory-leak
Browse files Browse the repository at this point in the history
creating new ticker each time leaks resources
  • Loading branch information
shotasilagadzetaal authored Jul 9, 2024
2 parents 5d6f580 + 575ae4f commit e8dc02b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ func (p *Peer) reconnect() {
p.logger.Warn("Failed to connect to peer", slog.String(errKey, connectErr.Error()))
}

ticker := time.NewTicker(reconnectInterval)
for {
select {
case <-time.NewTicker(reconnectInterval).C:
case <-ticker.C:
if p.Connected() || p.Connecting() {
continue
}
Expand Down

0 comments on commit e8dc02b

Please sign in to comment.