diff --git a/waku/v2/protocol/peer_exchange/enr_cache.go b/waku/v2/protocol/peer_exchange/enr_cache.go index 382a9d5b..af8f1423 100644 --- a/waku/v2/protocol/peer_exchange/enr_cache.go +++ b/waku/v2/protocol/peer_exchange/enr_cache.go @@ -7,21 +7,21 @@ import ( "sync" "github.com/ethereum/go-ethereum/p2p/enode" - lru "github.com/hashicorp/golang-lru" + "github.com/hashicorp/golang-lru/simplelru" "github.com/waku-org/go-waku/waku/v2/protocol/peer_exchange/pb" ) -// there is Arccache which is also thread safe but it is too verbose for the use-case and adds unnecessary overhead +// simpleLRU internal uses container/list, which is ring buffer(double linked list) type enrCache struct { // using lru, saves us from periodically cleaning the cache to maintain a certain size - data *lru.Cache + data *simplelru.LRU rng *rand.Rand mu sync.RWMutex } // err on negative size func newEnrCache(size int) (*enrCache, error) { - inner, err := lru.New(size) + inner, err := simplelru.NewLRU(size, nil) return &enrCache{ data: inner, rng: rand.New(rand.NewSource(rand.Int63())),