[p2p] fix the panic at cooldown cache

pull/4049/head
Jacky Wang 3 years ago
parent fc94354283
commit 8f24ee77b2
No known key found for this signature in database
GPG Key ID: 1085CE5F4FF5842C
  1. 6
      p2p/stream/common/streammanager/cooldown.go

@ -27,11 +27,13 @@ func newCoolDownCache() *coolDownCache {
// Has check and add the peer ID to the cache
func (cache *coolDownCache) Has(id peer.ID) bool {
has := cache.timeCache.Has(string(id))
cache.timeCache.Add(string(id))
if !has {
cache.timeCache.Add(string(id))
}
return has
}
// Reset reset the cooldown cache
// Reset the cool down cache
func (cache *coolDownCache) Reset() {
cache.timeCache.Q = list.New()
cache.timeCache.M = make(map[string]time.Time)

Loading…
Cancel
Save