func (uk *utxoKeeper) expireWorker() {
ticker := time.NewTicker(1000 * time.Millisecond)
+ defer ticker.Stop()
+
for now := range ticker.C {
uk.expireReservation(now)
}
}
+
func (uk *utxoKeeper) expireReservation(t time.Time) {
uk.mtx.Lock()
defer uk.mtx.Unlock()
return nil, errPeerDropped
}
- waitTicker := time.NewTimer(syncTimeout)
+ timeout := time.NewTimer(syncTimeout)
+ defer timeout.Stop()
+
for {
select {
case msg := <-bk.blockProcessCh:
continue
}
return msg.block, nil
- case <-waitTicker.C:
+ case <-timeout.C:
return nil, errors.Wrap(errRequestTimeout, "requireBlock")
}
}
return nil, errPeerDropped
}
- waitTicker := time.NewTimer(syncTimeout)
+ timeout := time.NewTimer(syncTimeout)
+ defer timeout.Stop()
+
for {
select {
case msg := <-bk.blocksProcessCh:
continue
}
return msg.blocks, nil
- case <-waitTicker.C:
+ case <-timeout.C:
return nil, errors.Wrap(errRequestTimeout, "requireBlocks")
}
}
return nil, errPeerDropped
}
- waitTicker := time.NewTimer(syncTimeout)
+ timeout := time.NewTimer(syncTimeout)
+ defer timeout.Stop()
+
for {
select {
case msg := <-bk.headersProcessCh:
continue
}
return msg.headers, nil
- case <-waitTicker.C:
+ case <-timeout.C:
return nil, errors.Wrap(errRequestTimeout, "requireHeaders")
}
}
return
}
syncTicker := time.NewTicker(syncCycle)
+ defer syncTicker.Stop()
+
for {
<-syncTicker.C
if update := bk.startSync(); !update {
// GetChannels implements Reactor
func (pr *ProtocolReactor) GetChannels() []*connection.ChannelDescriptor {
return []*connection.ChannelDescriptor{
- &connection.ChannelDescriptor{
+ {
ID: BlockchainChannel,
Priority: 5,
SendQueueCapacity: 100,
return errStatusRequest
}
- checkTicker := time.NewTimer(handshakeCheckPerid)
- timeoutTicker := time.NewTimer(handshakeTimeout)
+ checkTicker := time.NewTicker(handshakeCheckPerid)
+ defer checkTicker.Stop()
+ timeout := time.NewTimer(handshakeTimeout)
+ defer timeout.Stop()
for {
select {
case <-checkTicker.C:
return nil
}
- case <-timeoutTicker.C:
+ case <-timeout.C:
return errProtocolHandshakeTimeout
}
}
func (c *MConnection) OnStop() {
c.BaseService.OnStop()
c.flushTimer.Stop()
+ c.pingTimer.Stop()
+ c.chStatsTimer.Stop()
if c.quit != nil {
close(c.quit)
}
if nextRegisterTimer != nil {
nextRegisterTimer.Stop()
}
+ refreshTimer.Stop()
+ bucketRefreshTimer.Stop()
}()
resetNextTicket := func() {
ticket, timeout := net.ticketStore.nextFilteredTicket()
<-topicRegisterLookupTick.C
statsDump := time.NewTicker(10 * time.Second)
+ defer statsDump.Stop()
loop:
for {
func (tp *TxPool) orphanExpireWorker() {
ticker := time.NewTicker(orphanExpireScanInterval)
+ defer ticker.Stop()
+
for now := range ticker.C {
tp.ExpireOrphan(now)
}