Skip to content

Commit bbe974d

Browse files
committed
refactor: [#1519] rename SwarmHandle to CoordinatorHandle
1 parent 290c9eb commit bbe974d

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

packages/swarm-coordination-registry/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tokio::sync::Mutex;
99
use torrust_tracker_clock::clock;
1010

1111
pub type Registry = swarm::registry::Registry;
12-
pub type SwarmHandle = Arc<Mutex<Coordinator>>;
12+
pub type CoordinatorHandle = Arc<Mutex<Coordinator>>;
1313
pub type Coordinator = swarm::coordinator::Coordinator;
1414

1515
/// Working version, for production.

packages/swarm-coordination-registry/src/swarm/registry.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads
1212
use crate::event::sender::Sender;
1313
use crate::event::Event;
1414
use crate::swarm::coordinator::Coordinator;
15-
use crate::SwarmHandle;
15+
use crate::CoordinatorHandle;
1616

1717
#[derive(Default)]
1818
pub struct Registry {
19-
swarms: SkipMap<InfoHash, SwarmHandle>,
19+
swarms: SkipMap<InfoHash, CoordinatorHandle>,
2020
event_sender: Sender,
2121
}
2222

@@ -60,7 +60,7 @@ impl Registry {
6060
let number_of_downloads = opt_persistent_torrent.unwrap_or_default();
6161

6262
let new_swarm_handle =
63-
SwarmHandle::new(Coordinator::new(info_hash, number_of_downloads, self.event_sender.clone()).into());
63+
CoordinatorHandle::new(Coordinator::new(info_hash, number_of_downloads, self.event_sender.clone()).into());
6464

6565
let new_swarm_handle = self.swarms.get_or_insert(*info_hash, new_swarm_handle);
6666

@@ -107,7 +107,7 @@ impl Registry {
107107
///
108108
/// An `Option` containing the removed torrent entry if it existed.
109109
#[must_use]
110-
pub async fn remove(&self, key: &InfoHash) -> Option<SwarmHandle> {
110+
pub async fn remove(&self, key: &InfoHash) -> Option<CoordinatorHandle> {
111111
let swarm_handle = self.swarms.remove(key).map(|entry| entry.value().clone());
112112

113113
if let Some(event_sender) = self.event_sender.as_deref() {
@@ -123,7 +123,7 @@ impl Registry {
123123
///
124124
/// An `Option` containing the tracked torrent handle if found.
125125
#[must_use]
126-
pub fn get(&self, key: &InfoHash) -> Option<SwarmHandle> {
126+
pub fn get(&self, key: &InfoHash) -> Option<CoordinatorHandle> {
127127
let maybe_entry = self.swarms.get(key);
128128
maybe_entry.map(|entry| entry.value().clone())
129129
}
@@ -138,7 +138,7 @@ impl Registry {
138138
///
139139
/// A vector of `(InfoHash, TorrentEntry)` tuples.
140140
#[must_use]
141-
pub fn get_paginated(&self, pagination: Option<&Pagination>) -> Vec<(InfoHash, SwarmHandle)> {
141+
pub fn get_paginated(&self, pagination: Option<&Pagination>) -> Vec<(InfoHash, CoordinatorHandle)> {
142142
match pagination {
143143
Some(pagination) => self
144144
.swarms
@@ -366,7 +366,7 @@ impl Registry {
366366
continue;
367367
}
368368

369-
let entry = SwarmHandle::new(Coordinator::new(info_hash, *completed, self.event_sender.clone()).into());
369+
let entry = CoordinatorHandle::new(Coordinator::new(info_hash, *completed, self.event_sender.clone()).into());
370370

371371
// Since SkipMap is lock-free the torrent could have been inserted
372372
// after checking if it exists.
@@ -853,7 +853,7 @@ mod tests {
853853

854854
use crate::swarm::registry::Registry;
855855
use crate::tests::{sample_info_hash, sample_peer};
856-
use crate::{Coordinator, SwarmHandle};
856+
use crate::{Coordinator, CoordinatorHandle};
857857

858858
/// `TorrentEntry` data is not directly accessible. It's only
859859
/// accessible through the trait methods. We need this temporary
@@ -865,7 +865,7 @@ mod tests {
865865
number_of_peers: usize,
866866
}
867867

868-
async fn torrent_entry_info(swarm_handle: SwarmHandle) -> TorrentEntryInfo {
868+
async fn torrent_entry_info(swarm_handle: CoordinatorHandle) -> TorrentEntryInfo {
869869
let torrent_guard = swarm_handle.lock().await;
870870
torrent_guard.clone().into()
871871
}

packages/tracker-core/src/torrent/repository/in_memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use torrust_tracker_configuration::{TrackerPolicy, TORRENT_PEERS_LIMIT};
77
use torrust_tracker_primitives::pagination::Pagination;
88
use torrust_tracker_primitives::swarm_metadata::{AggregateActiveSwarmMetadata, SwarmMetadata};
99
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch, NumberOfDownloads, NumberOfDownloadsBTreeMap};
10-
use torrust_tracker_swarm_coordination_registry::{Registry, SwarmHandle};
10+
use torrust_tracker_swarm_coordination_registry::{CoordinatorHandle, Registry};
1111

1212
/// In-memory repository for torrent entries.
1313
///
@@ -110,7 +110,7 @@ impl InMemoryTorrentRepository {
110110
///
111111
/// An `Option` containing the torrent entry if found.
112112
#[must_use]
113-
pub(crate) fn get(&self, key: &InfoHash) -> Option<SwarmHandle> {
113+
pub(crate) fn get(&self, key: &InfoHash) -> Option<CoordinatorHandle> {
114114
self.swarms.get(key)
115115
}
116116

@@ -128,7 +128,7 @@ impl InMemoryTorrentRepository {
128128
///
129129
/// A vector of `(InfoHash, TorrentEntry)` tuples.
130130
#[must_use]
131-
pub(crate) fn get_paginated(&self, pagination: Option<&Pagination>) -> Vec<(InfoHash, SwarmHandle)> {
131+
pub(crate) fn get_paginated(&self, pagination: Option<&Pagination>) -> Vec<(InfoHash, CoordinatorHandle)> {
132132
self.swarms.get_paginated(pagination)
133133
}
134134

0 commit comments

Comments
 (0)