mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Prevent infinite ticker leaks in kaspaminer (#1476)
* Prevent infinite tickers leaks in kaspaminer * Reset ticker in ConnectionManager instead of allocating a new one Co-authored-by: Ori Newman <orinewman1@gmail.com>
This commit is contained in:
parent
d281dabdb4
commit
280fa3de46
@ -167,6 +167,8 @@ func templatesLoop(client *minerClient, miningAddr util.Address,
|
||||
newTemplateChan <- template
|
||||
}
|
||||
getBlockTemplate()
|
||||
const tickerTime = 500 * time.Millisecond
|
||||
ticker := time.NewTicker(tickerTime)
|
||||
for {
|
||||
select {
|
||||
case <-stopChan:
|
||||
@ -174,7 +176,8 @@ func templatesLoop(client *minerClient, miningAddr util.Address,
|
||||
return
|
||||
case <-client.blockAddedNotificationChan:
|
||||
getBlockTemplate()
|
||||
case <-time.Tick(500 * time.Millisecond):
|
||||
ticker.Reset(tickerTime)
|
||||
case <-ticker.C:
|
||||
getBlockTemplate()
|
||||
}
|
||||
}
|
||||
|
@ -147,8 +147,7 @@ func (c *ConnectionManager) IsBanned(netConnection *netadapter.NetConnection) (b
|
||||
func (c *ConnectionManager) waitTillNextIteration() {
|
||||
select {
|
||||
case <-c.resetLoopChan:
|
||||
c.loopTicker.Stop()
|
||||
c.loopTicker = time.NewTicker(connectionsLoopInterval)
|
||||
c.loopTicker.Reset(connectionsLoopInterval)
|
||||
case <-c.loopTicker.C:
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user