add missed condition to collect an additional data, implement as shared config function

This commit is contained in:
yggverse 2025-07-08 21:07:30 +03:00
parent 3fa126ffa5
commit e238db4439
2 changed files with 5 additions and 1 deletions

View file

@ -225,6 +225,10 @@ impl StatisticsConfig {
}
}
}
/// Skip info-hash collection if not required by the configuration
pub fn collect_info_hash(&self) -> bool {
(self.interval != 0) & (self.write_json_to_file | self.write_bin_to_file)
}
}
impl Default for StatisticsConfig {

View file

@ -389,7 +389,7 @@ impl<I: Ip> TorrentMapShards<I> {
total_num_torrents += torrent_map_shard.len();
if config.statistics.write_json_to_file {
if config.statistics.collect_info_hash() {
info_hashes.reserve(total_num_torrents);
for (k, _) in torrent_map_shard.iter() {
info_hashes.push(*k)