From 1e66b061162fa3f564a278861bc31fb7820654fc Mon Sep 17 00:00:00 2001 From: dboehm-avalabs Date: Wed, 12 Apr 2023 08:03:36 -0400 Subject: [PATCH 1/2] Update linkedhashmap.go --- utils/linkedhashmap/linkedhashmap.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/linkedhashmap/linkedhashmap.go b/utils/linkedhashmap/linkedhashmap.go index e4c1b3f4ff95..963679dcaf03 100644 --- a/utils/linkedhashmap/linkedhashmap.go +++ b/utils/linkedhashmap/linkedhashmap.go @@ -57,8 +57,8 @@ func (lh *linkedHashmap[K, V]) Put(key K, val V) { } func (lh *linkedHashmap[K, V]) Get(key K) (V, bool) { - lh.lock.Lock() - defer lh.lock.Unlock() + lh.lock.RLock() + defer lh.lock.RUnlock() return lh.get(key) } From 90cb8375bb69c8fb94602c84cf92b9e64e0634bf Mon Sep 17 00:00:00 2001 From: dboehm-avalabs Date: Wed, 12 Apr 2023 10:43:08 -0400 Subject: [PATCH 2/2] Update linkedhashmap.go --- utils/linkedhashmap/linkedhashmap.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/linkedhashmap/linkedhashmap.go b/utils/linkedhashmap/linkedhashmap.go index 963679dcaf03..25e04d85ba14 100644 --- a/utils/linkedhashmap/linkedhashmap.go +++ b/utils/linkedhashmap/linkedhashmap.go @@ -71,22 +71,22 @@ func (lh *linkedHashmap[K, V]) Delete(key K) { } func (lh *linkedHashmap[K, V]) Len() int { - lh.lock.Lock() - defer lh.lock.Unlock() + lh.lock.RLock() + defer lh.lock.RUnlock() return lh.len() } func (lh *linkedHashmap[K, V]) Oldest() (K, V, bool) { - lh.lock.Lock() - defer lh.lock.Unlock() + lh.lock.RLock() + defer lh.lock.RUnlock() return lh.oldest() } func (lh *linkedHashmap[K, V]) Newest() (K, V, bool) { - lh.lock.Lock() - defer lh.lock.Unlock() + lh.lock.RLock() + defer lh.lock.RUnlock() return lh.newest() }