From 381a7bd02da4ade46c698d3f757023b969a937d6 Mon Sep 17 00:00:00 2001 From: Edgar Aroutiounian Date: Sun, 10 Nov 2019 22:01:51 -0800 Subject: [PATCH] [project] Fix two leaking tickers (#1821) --- consensus/consensus_v2.go | 1 + node/node_handler.go | 1 + 2 files changed, 2 insertions(+) diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 6d68c905e..591fb0dfe 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -1085,6 +1085,7 @@ func (consensus *Consensus) Start(blockChannel chan *types.Block, stopChan chan utils.Logger().Info().Time("time", time.Now()).Msg("[ConsensusMainLoop] Consensus started") defer close(stoppedChan) ticker := time.NewTicker(3 * time.Second) + defer ticker.Stop() consensus.consensusTimeout[timeoutBootstrap].Start() utils.Logger().Debug(). Uint64("viewID", consensus.viewID). diff --git a/node/node_handler.go b/node/node_handler.go index 947cbfd00..7d54d52ac 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -479,6 +479,7 @@ func (node *Node) pingMessageHandler(msgPayload []byte, sender libp2p_peer.ID) i // bootstrapConsensus is the a goroutine to check number of peers and start the consensus func (node *Node) bootstrapConsensus() { tick := time.NewTicker(5 * time.Second) + defer tick.Stop() lastPeerNum := node.numPeers for { select {