Skip to content

Commit bcf2338

Browse files
committed
refactor: [#1541] rename type alias PersistentTorrents to NumberOfDownloadsBTreeMap
1 parent a5a80b5 commit bcf2338

File tree

18 files changed

+48
-48
lines changed

18 files changed

+48
-48
lines changed

packages/primitives/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ use bittorrent_primitives::info_hash::InfoHash;
1919
pub type DurationSinceUnixEpoch = Duration;
2020

2121
pub type NumberOfDownloads = u32;
22-
pub type PersistentTorrents = BTreeMap<InfoHash, NumberOfDownloads>;
22+
pub type NumberOfDownloadsBTreeMap = BTreeMap<InfoHash, NumberOfDownloads>;

packages/torrent-repository-benchmarking/src/repository/dash_map_mutex_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use dashmap::DashMap;
55
use torrust_tracker_configuration::TrackerPolicy;
66
use torrust_tracker_primitives::pagination::Pagination;
77
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
8-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
8+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
99

1010
use super::Repository;
1111
use crate::entry::peer_list::PeerList;
@@ -77,7 +77,7 @@ where
7777
}
7878
}
7979

80-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
80+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
8181
for (info_hash, completed) in persistent_torrents {
8282
if self.torrents.contains_key(info_hash) {
8383
continue;

packages/torrent-repository-benchmarking/src/repository/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bittorrent_primitives::info_hash::InfoHash;
22
use torrust_tracker_configuration::TrackerPolicy;
33
use torrust_tracker_primitives::pagination::Pagination;
44
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
5-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
5+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
66

77
pub mod dash_map_mutex_std;
88
pub mod rw_lock_std;
@@ -19,7 +19,7 @@ pub trait Repository<T>: Debug + Default + Sized + 'static {
1919
fn get(&self, key: &InfoHash) -> Option<T>;
2020
fn get_metrics(&self) -> AggregateSwarmMetadata;
2121
fn get_paginated(&self, pagination: Option<&Pagination>) -> Vec<(InfoHash, T)>;
22-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents);
22+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap);
2323
fn remove(&self, key: &InfoHash) -> Option<T>;
2424
fn remove_inactive_peers(&self, current_cutoff: DurationSinceUnixEpoch);
2525
fn remove_peerless_torrents(&self, policy: &TrackerPolicy);
@@ -32,7 +32,7 @@ pub trait RepositoryAsync<T>: Debug + Default + Sized + 'static {
3232
fn get(&self, key: &InfoHash) -> impl std::future::Future<Output = Option<T>> + Send;
3333
fn get_metrics(&self) -> impl std::future::Future<Output = AggregateSwarmMetadata> + Send;
3434
fn get_paginated(&self, pagination: Option<&Pagination>) -> impl std::future::Future<Output = Vec<(InfoHash, T)>> + Send;
35-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents) -> impl std::future::Future<Output = ()> + Send;
35+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) -> impl std::future::Future<Output = ()> + Send;
3636
fn remove(&self, key: &InfoHash) -> impl std::future::Future<Output = Option<T>> + Send;
3737
fn remove_inactive_peers(&self, current_cutoff: DurationSinceUnixEpoch) -> impl std::future::Future<Output = ()> + Send;
3838
fn remove_peerless_torrents(&self, policy: &TrackerPolicy) -> impl std::future::Future<Output = ()> + Send;

packages/torrent-repository-benchmarking/src/repository/rw_lock_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bittorrent_primitives::info_hash::InfoHash;
22
use torrust_tracker_configuration::TrackerPolicy;
33
use torrust_tracker_primitives::pagination::Pagination;
44
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
5-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
5+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
66

77
use super::Repository;
88
use crate::entry::peer_list::PeerList;
@@ -92,7 +92,7 @@ where
9292
}
9393
}
9494

95-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
95+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
9696
let mut torrents = self.get_torrents_mut();
9797

9898
for (info_hash, downloaded) in persistent_torrents {

packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bittorrent_primitives::info_hash::InfoHash;
44
use torrust_tracker_configuration::TrackerPolicy;
55
use torrust_tracker_primitives::pagination::Pagination;
66
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
7-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
7+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
88

99
use super::Repository;
1010
use crate::entry::peer_list::PeerList;
@@ -87,7 +87,7 @@ where
8787
}
8888
}
8989

90-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
90+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
9191
let mut torrents = self.get_torrents_mut();
9292

9393
for (info_hash, completed) in persistent_torrents {

packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_tokio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use futures::{Future, FutureExt};
88
use torrust_tracker_configuration::TrackerPolicy;
99
use torrust_tracker_primitives::pagination::Pagination;
1010
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
11-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
11+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
1212

1313
use super::RepositoryAsync;
1414
use crate::entry::peer_list::PeerList;
@@ -101,7 +101,7 @@ where
101101
metrics
102102
}
103103

104-
async fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
104+
async fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
105105
let mut db = self.get_torrents_mut();
106106

107107
for (info_hash, completed) in persistent_torrents {

packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bittorrent_primitives::info_hash::InfoHash;
22
use torrust_tracker_configuration::TrackerPolicy;
33
use torrust_tracker_primitives::pagination::Pagination;
44
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
5-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
5+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
66

77
use super::RepositoryAsync;
88
use crate::entry::peer_list::PeerList;
@@ -98,7 +98,7 @@ where
9898
metrics
9999
}
100100

101-
async fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
101+
async fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
102102
let mut torrents = self.get_torrents_mut().await;
103103

104104
for (info_hash, completed) in persistent_torrents {

packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bittorrent_primitives::info_hash::InfoHash;
44
use torrust_tracker_configuration::TrackerPolicy;
55
use torrust_tracker_primitives::pagination::Pagination;
66
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
7-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
7+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
88

99
use super::RepositoryAsync;
1010
use crate::entry::peer_list::PeerList;
@@ -92,7 +92,7 @@ where
9292
metrics
9393
}
9494

95-
async fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
95+
async fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
9696
let mut torrents = self.get_torrents_mut().await;
9797

9898
for (info_hash, completed) in persistent_torrents {

packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_tokio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bittorrent_primitives::info_hash::InfoHash;
44
use torrust_tracker_configuration::TrackerPolicy;
55
use torrust_tracker_primitives::pagination::Pagination;
66
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
7-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
7+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
88

99
use super::RepositoryAsync;
1010
use crate::entry::peer_list::PeerList;
@@ -95,7 +95,7 @@ where
9595
metrics
9696
}
9797

98-
async fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
98+
async fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
9999
let mut db = self.get_torrents_mut().await;
100100

101101
for (info_hash, completed) in persistent_torrents {

packages/torrent-repository-benchmarking/src/repository/skip_map_mutex_std.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crossbeam_skiplist::SkipMap;
55
use torrust_tracker_configuration::TrackerPolicy;
66
use torrust_tracker_primitives::pagination::Pagination;
77
use torrust_tracker_primitives::swarm_metadata::{AggregateSwarmMetadata, SwarmMetadata};
8-
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
8+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
99

1010
use super::Repository;
1111
use crate::entry::peer_list::PeerList;
@@ -100,7 +100,7 @@ where
100100
}
101101
}
102102

103-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
103+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
104104
for (info_hash, completed) in persistent_torrents {
105105
if self.torrents.contains_key(info_hash) {
106106
continue;
@@ -193,7 +193,7 @@ where
193193
}
194194
}
195195

196-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
196+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
197197
for (info_hash, completed) in persistent_torrents {
198198
if self.torrents.contains_key(info_hash) {
199199
continue;
@@ -286,7 +286,7 @@ where
286286
}
287287
}
288288

289-
fn import_persistent(&self, persistent_torrents: &PersistentTorrents) {
289+
fn import_persistent(&self, persistent_torrents: &NumberOfDownloadsBTreeMap) {
290290
for (info_hash, completed) in persistent_torrents {
291291
if self.torrents.contains_key(info_hash) {
292292
continue;

0 commit comments

Comments
 (0)