mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-20 11:24:21 -07:00
storage/memorybysubnet: delete empty subnet buckets
This commit is contained in:
@@ -547,6 +547,9 @@ func (s *peerStore) collectGarbage(cutoff time.Time) error {
|
||||
delete(shard.swarms[ih].leechers[subnet], pk)
|
||||
}
|
||||
}
|
||||
if len(shard.swarms[ih].leechers[subnet]) == 0 {
|
||||
delete(shard.swarms[ih].leechers, subnet)
|
||||
}
|
||||
}
|
||||
|
||||
for subnet := range shard.swarms[ih].seeders {
|
||||
@@ -555,6 +558,9 @@ func (s *peerStore) collectGarbage(cutoff time.Time) error {
|
||||
delete(shard.swarms[ih].seeders[subnet], pk)
|
||||
}
|
||||
}
|
||||
if len(shard.swarms[ih].seeders[subnet]) == 0 {
|
||||
delete(shard.swarms[ih].seeders, subnet)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(jzelinskie): fix this to sum all peers in all subnets
|
||||
|
||||
Reference in New Issue
Block a user