storage/memorybysubnet: delete empty subnet buckets

This commit is contained in:
Jimmy Zelinskie 2017-05-03 21:28:38 -04:00
parent cb6a3be2ac
commit b013106f89

View file

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