Skip to content

Commit a5a80b5

Browse files
committed
refactor: [#1541] rename type alias PersistentTorrent to NumberOfDownloads
1 parent 0508a6a commit a5a80b5

File tree

17 files changed

+48
-48
lines changed

17 files changed

+48
-48
lines changed

packages/primitives/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ use bittorrent_primitives::info_hash::InfoHash;
1818
/// Duration since the Unix Epoch.
1919
pub type DurationSinceUnixEpoch = Duration;
2020

21-
pub type PersistentTorrent = u32;
22-
pub type PersistentTorrents = BTreeMap<InfoHash, PersistentTorrent>;
21+
pub type NumberOfDownloads = u32;
22+
pub type PersistentTorrents = 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, PersistentTorrent, PersistentTorrents};
8+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
99

1010
use super::Repository;
1111
use crate::entry::peer_list::PeerList;
@@ -22,7 +22,7 @@ where
2222
EntryMutexStd: EntrySync,
2323
EntrySingle: Entry,
2424
{
25-
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<PersistentTorrent>) -> bool {
25+
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<NumberOfDownloads>) -> bool {
2626
// todo: load persistent torrent data if provided
2727

2828
if let Some(entry) = self.torrents.get(info_hash) {

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, PersistentTorrent, PersistentTorrents};
5+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
66

77
pub mod dash_map_mutex_std;
88
pub mod rw_lock_std;
@@ -23,7 +23,7 @@ pub trait Repository<T>: Debug + Default + Sized + 'static {
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);
26-
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, opt_persistent_torrent: Option<PersistentTorrent>) -> bool;
26+
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, opt_persistent_torrent: Option<NumberOfDownloads>) -> bool;
2727
fn get_swarm_metadata(&self, info_hash: &InfoHash) -> Option<SwarmMetadata>;
2828
}
2929

@@ -40,7 +40,7 @@ pub trait RepositoryAsync<T>: Debug + Default + Sized + 'static {
4040
&self,
4141
info_hash: &InfoHash,
4242
peer: &peer::Peer,
43-
opt_persistent_torrent: Option<PersistentTorrent>,
43+
opt_persistent_torrent: Option<NumberOfDownloads>,
4444
) -> impl std::future::Future<Output = bool> + Send;
4545
fn get_swarm_metadata(&self, info_hash: &InfoHash) -> impl std::future::Future<Output = Option<SwarmMetadata>> + Send;
4646
}

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, PersistentTorrent, PersistentTorrents};
5+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
66

77
use super::Repository;
88
use crate::entry::peer_list::PeerList;
@@ -45,7 +45,7 @@ impl Repository<EntrySingle> for TorrentsRwLockStd
4545
where
4646
EntrySingle: Entry,
4747
{
48-
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<PersistentTorrent>) -> bool {
48+
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<NumberOfDownloads>) -> bool {
4949
// todo: load persistent torrent data if provided
5050

5151
let mut db = self.get_torrents_mut();

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, PersistentTorrent, PersistentTorrents};
7+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
88

99
use super::Repository;
1010
use crate::entry::peer_list::PeerList;
@@ -32,7 +32,7 @@ where
3232
EntryMutexStd: EntrySync,
3333
EntrySingle: Entry,
3434
{
35-
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<PersistentTorrent>) -> bool {
35+
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<NumberOfDownloads>) -> bool {
3636
// todo: load persistent torrent data if provided
3737

3838
let maybe_entry = self.get_torrents().get(info_hash).cloned();

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, PersistentTorrent, PersistentTorrents};
11+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
1212

1313
use super::RepositoryAsync;
1414
use crate::entry::peer_list::PeerList;
@@ -40,7 +40,7 @@ where
4040
&self,
4141
info_hash: &InfoHash,
4242
peer: &peer::Peer,
43-
_opt_persistent_torrent: Option<PersistentTorrent>,
43+
_opt_persistent_torrent: Option<NumberOfDownloads>,
4444
) -> bool {
4545
// todo: load persistent torrent data if provided
4646

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, PersistentTorrent, PersistentTorrents};
5+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
66

77
use super::RepositoryAsync;
88
use crate::entry::peer_list::PeerList;
@@ -50,7 +50,7 @@ where
5050
&self,
5151
info_hash: &InfoHash,
5252
peer: &peer::Peer,
53-
_opt_persistent_torrent: Option<PersistentTorrent>,
53+
_opt_persistent_torrent: Option<NumberOfDownloads>,
5454
) -> bool {
5555
// todo: load persistent torrent data if provided
5656

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, PersistentTorrent, PersistentTorrents};
7+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
88

99
use super::RepositoryAsync;
1010
use crate::entry::peer_list::PeerList;
@@ -38,7 +38,7 @@ where
3838
&self,
3939
info_hash: &InfoHash,
4040
peer: &peer::Peer,
41-
_opt_persistent_torrent: Option<PersistentTorrent>,
41+
_opt_persistent_torrent: Option<NumberOfDownloads>,
4242
) -> bool {
4343
// todo: load persistent torrent data if provided
4444

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, PersistentTorrent, PersistentTorrents};
7+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
88

99
use super::RepositoryAsync;
1010
use crate::entry::peer_list::PeerList;
@@ -38,7 +38,7 @@ where
3838
&self,
3939
info_hash: &InfoHash,
4040
peer: &peer::Peer,
41-
_opt_persistent_torrent: Option<PersistentTorrent>,
41+
_opt_persistent_torrent: Option<NumberOfDownloads>,
4242
) -> bool {
4343
// todo: load persistent torrent data if provided
4444

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, PersistentTorrent, PersistentTorrents};
8+
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, PersistentTorrents};
99

1010
use super::Repository;
1111
use crate::entry::peer_list::PeerList;
@@ -38,7 +38,7 @@ where
3838
///
3939
/// Returns `true` if the number of downloads was increased because the peer
4040
/// completed the download.
41-
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, opt_persistent_torrent: Option<PersistentTorrent>) -> bool {
41+
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, opt_persistent_torrent: Option<NumberOfDownloads>) -> bool {
4242
if let Some(existing_entry) = self.torrents.get(info_hash) {
4343
existing_entry.value().upsert_peer(peer)
4444
} else {
@@ -146,7 +146,7 @@ where
146146
EntryRwLockParkingLot: EntrySync,
147147
EntrySingle: Entry,
148148
{
149-
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<PersistentTorrent>) -> bool {
149+
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<NumberOfDownloads>) -> bool {
150150
// todo: load persistent torrent data if provided
151151

152152
let entry = self.torrents.get_or_insert(*info_hash, Arc::default());
@@ -239,7 +239,7 @@ where
239239
EntryMutexParkingLot: EntrySync,
240240
EntrySingle: Entry,
241241
{
242-
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<PersistentTorrent>) -> bool {
242+
fn upsert_peer(&self, info_hash: &InfoHash, peer: &peer::Peer, _opt_persistent_torrent: Option<NumberOfDownloads>) -> bool {
243243
// todo: load persistent torrent data if provided
244244

245245
let entry = self.torrents.get_or_insert(*info_hash, Arc::default());

0 commit comments

Comments
 (0)