Skip to content

Commit ed1148f

Browse files
committed
refactor: [#1205] remove unused Tracker field
1 parent 5021337 commit ed1148f

File tree

11 files changed

+21
-88
lines changed

11 files changed

+21
-88
lines changed

src/bootstrap/app.rs

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ pub fn initialize_app_container(configuration: &Configuration) -> AppContainer {
117117

118118
let tracker = Arc::new(initialize_tracker(
119119
configuration,
120-
&whitelist_authorization,
121120
&in_memory_torrent_repository,
122121
&db_torrent_repository,
123122
));

src/core/mod.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,6 @@ pub struct Tracker {
474474
/// The tracker configuration.
475475
config: Core,
476476

477-
/// The service to check is a torrent is whitelisted.
478-
_whitelist_authorization: Arc<whitelist::authorization::Authorization>,
479-
480477
/// The in-memory torrents repository.
481478
in_memory_torrent_repository: Arc<InMemoryTorrentRepository>,
482479

@@ -534,13 +531,11 @@ impl Tracker {
534531
/// Will return a `databases::error::Error` if unable to connect to database. The `Tracker` is responsible for the persistence.
535532
pub fn new(
536533
config: &Core,
537-
whitelist_authorization: &Arc<whitelist::authorization::Authorization>,
538534
in_memory_torrent_repository: &Arc<InMemoryTorrentRepository>,
539535
db_torrent_repository: &Arc<DatabasePersistentTorrentRepository>,
540536
) -> Result<Tracker, databases::error::Error> {
541537
Ok(Tracker {
542538
config: config.clone(),
543-
_whitelist_authorization: whitelist_authorization.clone(),
544539
in_memory_torrent_repository: in_memory_torrent_repository.clone(),
545540
db_torrent_repository: db_torrent_repository.clone(),
546541
})
@@ -719,7 +714,6 @@ mod tests {
719714

720715
let tracker = Arc::new(initialize_tracker(
721716
&config,
722-
&whitelist_authorization,
723717
&in_memory_torrent_repository,
724718
&db_torrent_repository,
725719
));
@@ -735,7 +729,7 @@ mod tests {
735729
let (
736730
_database,
737731
_in_memory_whitelist,
738-
whitelist_authorization,
732+
_whitelist_authorization,
739733
_authentication_service,
740734
in_memory_torrent_repository,
741735
db_torrent_repository,
@@ -744,7 +738,6 @@ mod tests {
744738

745739
let tracker = Arc::new(initialize_tracker(
746740
&config,
747-
&whitelist_authorization,
748741
&in_memory_torrent_repository,
749742
&db_torrent_repository,
750743
));
@@ -772,12 +765,7 @@ mod tests {
772765

773766
let whitelist_manager = initialize_whitelist_manager(database.clone(), in_memory_whitelist.clone());
774767

775-
let tracker = initialize_tracker(
776-
&config,
777-
&whitelist_authorization,
778-
&in_memory_torrent_repository,
779-
&db_torrent_repository,
780-
);
768+
let tracker = initialize_tracker(&config, &in_memory_torrent_repository, &db_torrent_repository);
781769

782770
let scrape_handler = Arc::new(ScrapeHandler::new(&whitelist_authorization, &in_memory_torrent_repository));
783771

@@ -791,19 +779,14 @@ mod tests {
791779
let (
792780
_database,
793781
_in_memory_whitelist,
794-
whitelist_authorization,
782+
_whitelist_authorization,
795783
_authentication_service,
796784
in_memory_torrent_repository,
797785
db_torrent_repository,
798786
torrents_manager,
799787
) = initialize_tracker_dependencies(&config);
800788

801-
let tracker = initialize_tracker(
802-
&config,
803-
&whitelist_authorization,
804-
&in_memory_torrent_repository,
805-
&db_torrent_repository,
806-
);
789+
let tracker = initialize_tracker(&config, &in_memory_torrent_repository, &db_torrent_repository);
807790

808791
(tracker, torrents_manager, in_memory_torrent_repository)
809792
}

src/core/scrape_handler.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use std::sync::Arc;
22

33
use bittorrent_primitives::info_hash::InfoHash;
4-
use torrust_tracker_primitives::{core::ScrapeData, swarm_metadata::SwarmMetadata};
4+
use torrust_tracker_primitives::core::ScrapeData;
5+
use torrust_tracker_primitives::swarm_metadata::SwarmMetadata;
56

6-
use super::{torrent::repository::in_memory::InMemoryTorrentRepository, whitelist};
7+
use super::torrent::repository::in_memory::InMemoryTorrentRepository;
8+
use super::whitelist;
79

810
pub struct ScrapeHandler {
911
/// The service to check is a torrent is whitelisted.
@@ -53,12 +55,10 @@ mod tests {
5355
use torrust_tracker_primitives::core::ScrapeData;
5456
use torrust_tracker_test_helpers::configuration;
5557

56-
use crate::core::{
57-
torrent::repository::in_memory::InMemoryTorrentRepository,
58-
whitelist::{self, repository::in_memory::InMemoryWhitelist},
59-
};
60-
6158
use super::ScrapeHandler;
59+
use crate::core::torrent::repository::in_memory::InMemoryTorrentRepository;
60+
use crate::core::whitelist::repository::in_memory::InMemoryWhitelist;
61+
use crate::core::whitelist::{self};
6262

6363
fn scrape_handler() -> ScrapeHandler {
6464
let config = configuration::ephemeral_public();

src/core/services/mod.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use torrust_tracker_configuration::Configuration;
1616
use super::databases::{self, Database};
1717
use super::torrent::repository::in_memory::InMemoryTorrentRepository;
1818
use super::torrent::repository::persisted::DatabasePersistentTorrentRepository;
19-
use super::whitelist;
2019
use super::whitelist::manager::WhiteListManager;
2120
use super::whitelist::repository::in_memory::InMemoryWhitelist;
2221
use super::whitelist::repository::persisted::DatabaseWhitelist;
@@ -30,16 +29,10 @@ use crate::core::Tracker;
3029
#[must_use]
3130
pub fn initialize_tracker(
3231
config: &Configuration,
33-
whitelist_authorization: &Arc<whitelist::authorization::Authorization>,
3432
in_memory_torrent_repository: &Arc<InMemoryTorrentRepository>,
3533
db_torrent_repository: &Arc<DatabasePersistentTorrentRepository>,
3634
) -> Tracker {
37-
match Tracker::new(
38-
&Arc::new(config).core,
39-
whitelist_authorization,
40-
in_memory_torrent_repository,
41-
db_torrent_repository,
42-
) {
35+
match Tracker::new(&Arc::new(config).core, in_memory_torrent_repository, db_torrent_repository) {
4336
Ok(tracker) => tracker,
4437
Err(error) => {
4538
panic!("{}", error)

src/core/services/statistics/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ mod tests {
135135
let (
136136
_database,
137137
_in_memory_whitelist,
138-
whitelist_authorization,
138+
_whitelist_authorization,
139139
_authentication_service,
140140
in_memory_torrent_repository,
141141
db_torrent_repository,
@@ -147,7 +147,6 @@ mod tests {
147147

148148
let _tracker = Arc::new(initialize_tracker(
149149
&config,
150-
&whitelist_authorization,
151150
&in_memory_torrent_repository,
152151
&db_torrent_repository,
153152
));

src/core/services/torrent.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ mod tests {
127127
let (
128128
_database,
129129
_in_memory_whitelist,
130-
whitelist_authorization,
130+
_whitelist_authorization,
131131
_authentication_service,
132132
in_memory_torrent_repository,
133133
db_torrent_repository,
@@ -136,7 +136,6 @@ mod tests {
136136

137137
let tracker = Arc::new(initialize_tracker(
138138
config,
139-
&whitelist_authorization,
140139
&in_memory_torrent_repository,
141140
&db_torrent_repository,
142141
));

src/servers/http/v1/handlers/announce.rs

-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ mod tests {
289289

290290
let tracker = Arc::new(initialize_tracker(
291291
config,
292-
&whitelist_authorization,
293292
&in_memory_torrent_repository,
294293
&db_torrent_repository,
295294
));

src/servers/http/v1/handlers/scrape.rs

-4
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ mod tests {
202202

203203
let tracker = Arc::new(initialize_tracker(
204204
&config,
205-
&whitelist_authorization,
206205
&in_memory_torrent_repository,
207206
&db_torrent_repository,
208207
));
@@ -237,7 +236,6 @@ mod tests {
237236

238237
let tracker = Arc::new(initialize_tracker(
239238
&config,
240-
&whitelist_authorization,
241239
&in_memory_torrent_repository,
242240
&db_torrent_repository,
243241
));
@@ -272,7 +270,6 @@ mod tests {
272270

273271
let tracker = Arc::new(initialize_tracker(
274272
&config,
275-
&whitelist_authorization,
276273
&in_memory_torrent_repository,
277274
&db_torrent_repository,
278275
));
@@ -307,7 +304,6 @@ mod tests {
307304

308305
let tracker = Arc::new(initialize_tracker(
309306
&config,
310-
&whitelist_authorization,
311307
&in_memory_torrent_repository,
312308
&db_torrent_repository,
313309
));

src/servers/http/v1/services/announce.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ mod tests {
7676
let (
7777
_database,
7878
_in_memory_whitelist,
79-
whitelist_authorization,
79+
_whitelist_authorization,
8080
_authentication_service,
8181
in_memory_torrent_repository,
8282
db_torrent_repository,
@@ -85,12 +85,7 @@ mod tests {
8585
let (stats_event_sender, _stats_repository) = statistics::setup::factory(config.core.tracker_usage_statistics);
8686
let stats_event_sender = Arc::new(stats_event_sender);
8787

88-
let tracker = initialize_tracker(
89-
&config,
90-
&whitelist_authorization,
91-
&in_memory_torrent_repository,
92-
&db_torrent_repository,
93-
);
88+
let tracker = initialize_tracker(&config, &in_memory_torrent_repository, &db_torrent_repository);
9489

9590
(tracker, stats_event_sender)
9691
}
@@ -147,20 +142,14 @@ mod tests {
147142
let (
148143
_database,
149144
_in_memory_whitelist,
150-
whitelist_authorization,
145+
_whitelist_authorization,
151146
_authentication_service,
152147
in_memory_torrent_repository,
153148
db_torrent_repository,
154149
_torrents_manager,
155150
) = initialize_tracker_dependencies(&config);
156151

157-
Tracker::new(
158-
&config.core,
159-
&whitelist_authorization,
160-
&in_memory_torrent_repository,
161-
&db_torrent_repository,
162-
)
163-
.unwrap()
152+
Tracker::new(&config.core, &in_memory_torrent_repository, &db_torrent_repository).unwrap()
164153
}
165154

166155
#[tokio::test]

src/servers/http/v1/services/scrape.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ mod tests {
101101

102102
let tracker = Arc::new(initialize_tracker(
103103
&config,
104-
&whitelist_authorization,
105104
&in_memory_torrent_repository,
106105
&db_torrent_repository,
107106
));
@@ -144,15 +143,7 @@ mod tests {
144143
_torrents_manager,
145144
) = initialize_tracker_dependencies(&config);
146145

147-
let tracker = Arc::new(
148-
Tracker::new(
149-
&config.core,
150-
&whitelist_authorization,
151-
&in_memory_torrent_repository,
152-
&db_torrent_repository,
153-
)
154-
.unwrap(),
155-
);
146+
let tracker = Arc::new(Tracker::new(&config.core, &in_memory_torrent_repository, &db_torrent_repository).unwrap());
156147

157148
let scrape_handler = Arc::new(ScrapeHandler::new(&whitelist_authorization, &in_memory_torrent_repository));
158149

src/servers/udp/handlers.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ mod tests {
542542

543543
let tracker = Arc::new(initialize_tracker(
544544
config,
545-
&whitelist_authorization,
546545
&in_memory_torrent_repository,
547546
&db_torrent_repository,
548547
));
@@ -667,15 +666,7 @@ mod tests {
667666
_torrents_manager,
668667
) = initialize_tracker_dependencies(&config);
669668

670-
let tracker = Arc::new(
671-
Tracker::new(
672-
&config.core,
673-
&whitelist_authorization,
674-
&in_memory_torrent_repository,
675-
&db_torrent_repository,
676-
)
677-
.unwrap(),
678-
);
669+
let tracker = Arc::new(Tracker::new(&config.core, &in_memory_torrent_repository, &db_torrent_repository).unwrap());
679670

680671
let scrape_handler = Arc::new(ScrapeHandler::new(&whitelist_authorization, &in_memory_torrent_repository));
681672

@@ -1505,13 +1496,7 @@ mod tests {
15051496
Arc::new(Some(Box::new(stats_event_sender_mock)));
15061497

15071498
let tracker = Arc::new(
1508-
core::Tracker::new(
1509-
&config.core,
1510-
&whitelist_authorization,
1511-
&in_memory_torrent_repository,
1512-
&db_torrent_repository,
1513-
)
1514-
.unwrap(),
1499+
core::Tracker::new(&config.core, &in_memory_torrent_repository, &db_torrent_repository).unwrap(),
15151500
);
15161501

15171502
let loopback_ipv4 = Ipv4Addr::new(127, 0, 0, 1);

0 commit comments

Comments
 (0)