@@ -290,11 +290,11 @@ type UniverseStats struct {
290290 statsCacheLogger * cacheLogger
291291 statsRefresh * time.Timer
292292
293- eventsMtx sync.Mutex
293+ eventsMtx sync.RWMutex
294294 assetEventsCache assetEventsCache
295295 eventsCacheLogger * cacheLogger
296296
297- syncStatsMtx sync.Mutex
297+ syncStatsMtx sync.RWMutex
298298 syncStatsCache * atomicSyncStatsCache
299299 syncStatsRefresh * time.Timer
300300}
@@ -635,7 +635,9 @@ func (u *UniverseStats) QueryAssetStatsPerDay(ctx context.Context,
635635 // First, we'll check to see if we already have a cached result for
636636 // this query.
637637 query := newEventQuery (q )
638+ u .eventsMtx .RLock ()
638639 cachedResult , err := u .assetEventsCache .Get (query )
640+ u .eventsMtx .RUnlock ()
639641 if err == nil {
640642 u .eventsCacheLogger .Hit ()
641643 return cachedResult , nil
@@ -750,13 +752,16 @@ func (u *UniverseStats) QuerySyncStats(ctx context.Context,
750752
751753 // First, check the cache to see if we already have a cached result for
752754 // this query.
755+ u .syncStatsMtx .RLock ()
753756 syncSnapshots := u .syncStatsCache .fetchQuery (q )
757+ u .syncStatsMtx .RUnlock ()
758+
754759 if syncSnapshots != nil {
755760 resp .SyncStats = syncSnapshots
756761 return resp , nil
757762 }
758763
759- // Otherwise, we'll grab the main mutex so we can qury the db then
764+ // Otherwise, we'll grab the main mutex so we can query the db then
760765 // cache the result.
761766 u .syncStatsMtx .Lock ()
762767 defer u .syncStatsMtx .Unlock ()
0 commit comments