mirror of
https://github.com/sot-tech/mochi.git
synced 2026-04-27 08:00:00 -07:00
storage: add Benchmarks for ScrapeSwarm, optimize implementations
This commit is contained in:
@@ -518,13 +518,14 @@ func (ps *peerStore) ScrapeSwarm(ih bittorrent.InfoHash, addressFamily bittorren
|
||||
shard := ps.shards[ps.shardIndex(ih, addressFamily)]
|
||||
shard.RLock()
|
||||
|
||||
if _, ok := shard.swarms[ih]; !ok {
|
||||
swarm, ok := shard.swarms[ih]
|
||||
if !ok {
|
||||
shard.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
resp.Incomplete = uint32(len(shard.swarms[ih].leechers))
|
||||
resp.Complete = uint32(len(shard.swarms[ih].seeders))
|
||||
resp.Incomplete = uint32(len(swarm.leechers))
|
||||
resp.Complete = uint32(len(swarm.seeders))
|
||||
shard.RUnlock()
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user