From 37596ac18805f4d058cbbfb59694af90ff579adb Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Fri, 20 Sep 2019 11:05:08 -0700 Subject: [PATCH] Is len(map) threadsafe? (#3535) --- beacon-chain/sync/peerstatus/peer_statuses.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beacon-chain/sync/peerstatus/peer_statuses.go b/beacon-chain/sync/peerstatus/peer_statuses.go index b9573f113..c0fae8865 100644 --- a/beacon-chain/sync/peerstatus/peer_statuses.go +++ b/beacon-chain/sync/peerstatus/peer_statuses.go @@ -35,6 +35,8 @@ func Delete(pid peer.ID) { // Count of peer statuses in cache. Threadsafe. func Count() int { + lock.RLock() + defer lock.RUnlock() return len(peerStatuses) }