fixed dht kbucket race

closes #836
This commit is contained in:
Juan Batiz-Benet 2015-03-04 08:28:46 -08:00
parent 04a3a66c6c
commit 4dd2e8fde9

View File

@ -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
}