mirror of
https://github.com/sot-tech/mochi.git
synced 2026-04-29 09:00:00 -07:00
Track the total size of the of the torrents map
This commit is contained in:
@@ -44,6 +44,10 @@ func NewStorage(cfg *config.Config) *Storage {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Storage) Len() int {
|
||||
return int(atomic.LoadInt32(&s.size))
|
||||
}
|
||||
|
||||
func (s *Storage) GetShardIndex(infohash string) uint32 {
|
||||
idx := fnv.New32()
|
||||
idx.Write([]byte(infohash))
|
||||
@@ -198,7 +202,7 @@ func (s *Storage) PurgeInactivePeers(purgeEmptyTorrents bool, before time.Time)
|
||||
|
||||
// Build a list of keys to process.
|
||||
index := 0
|
||||
maxkeys := int(atomic.LoadInt32(&s.size))
|
||||
maxkeys := s.Len()
|
||||
keys := make([]string, maxkeys)
|
||||
for i := range s.shards {
|
||||
shard := &s.shards[i]
|
||||
|
||||
Reference in New Issue
Block a user