From 3dbc2fd5bacabb81c5c69bb2fc3a83d5956cd836 Mon Sep 17 00:00:00 2001 From: Hlib Kanunnikov Date: Tue, 21 Feb 2023 12:10:42 +0100 Subject: [PATCH] fix(timecache): remove panic in first seen cache on Add (#522) --- timecache/first_seen_cache.go | 3 ++- timecache/time_cache.go | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/timecache/first_seen_cache.go b/timecache/first_seen_cache.go index f8626ae..351631c 100644 --- a/timecache/first_seen_cache.go +++ b/timecache/first_seen_cache.go @@ -29,7 +29,8 @@ func (tc FirstSeenCache) Add(s string) { _, ok := tc.m[s] if ok { - panic("putting the same entry twice not supported") + log.Debug("first-seen: got same entry") + return } // TODO(#515): Do GC in the background diff --git a/timecache/time_cache.go b/timecache/time_cache.go index f10ff21..2a67b4a 100644 --- a/timecache/time_cache.go +++ b/timecache/time_cache.go @@ -1,6 +1,12 @@ package timecache -import "time" +import ( + "time" + + logger "github.com/ipfs/go-log/v2" +) + +var log = logger.Logger("pubsub/timecache") type Strategy uint8