mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 19:30:44 +00:00
p2p/tracker: clean up code
This commit is contained in:
parent
1a482cac6a
commit
e89ff4a68a
1 changed files with 5 additions and 4 deletions
|
|
@ -139,7 +139,7 @@ func (t *Tracker) clean() {
|
|||
defer t.lock.Unlock()
|
||||
|
||||
if t.expire == nil {
|
||||
return
|
||||
return // Tracker was stopped.
|
||||
}
|
||||
|
||||
// Expire anything within a certain threshold (might be no items at all if
|
||||
|
|
@ -166,14 +166,15 @@ func (t *Tracker) clean() {
|
|||
t.schedule()
|
||||
}
|
||||
|
||||
// schedule starts a timer to trigger on the expiration of the first network
|
||||
// packet.
|
||||
// schedule starts a timer to trigger on the expiration of the first network packet.
|
||||
func (t *Tracker) schedule() {
|
||||
if t.expire.Len() == 0 {
|
||||
t.wake = nil
|
||||
return
|
||||
}
|
||||
t.wake = time.AfterFunc(time.Until(t.pending[t.expire.Front().Value.(uint64)].time.Add(t.timeout)), t.clean)
|
||||
nextID := t.expire.Front().Value.(uint64)
|
||||
nextTime := t.pending[nextID].time
|
||||
t.wake = time.AfterFunc(time.Until(nextTime.Add(t.timeout)), t.clean)
|
||||
}
|
||||
|
||||
// Stop reclaims resources of the tracker.
|
||||
|
|
|
|||
Loading…
Reference in a new issue