diff --git a/routing/kbucket/table.go b/routing/kbucket/table.go index a785bf8b5..7b10d8daf 100644 --- a/routing/kbucket/table.go +++ b/routing/kbucket/table.go @@ -185,9 +185,11 @@ func (rt *RoutingTable) NearestPeers(id ID, count int) []peer.ID { // Size returns the total number of peers in the routing table func (rt *RoutingTable) Size() int { var tot int + rt.tabLock.RLock() for _, buck := range rt.Buckets { tot += buck.Len() } + rt.tabLock.RUnlock() return tot }