From 575ae4f1f0f69b1c8504abc6116c727de62045f7 Mon Sep 17 00:00:00 2001 From: "shota.silagadze" Date: Mon, 8 Jul 2024 11:57:13 +0400 Subject: [PATCH] creating new ticker each time leaks resources --- peer.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index ef198fe..ce74ea6 100644 --- a/peer.go +++ b/peer.go @@ -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 }