Skip to content

Commit 5362a6d

Browse files
committedFeb 27, 2025
refactor: [#1309] remove unused code adn rename function
And other changes to make the convertion more explicit and clear.
1 parent ee2fc24 commit 5362a6d

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed
 

‎packages/axum-http-tracker-server/src/v1/handlers/announce.rs

+1-26
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
//! and resolve the client IP address.
55
use std::sync::Arc;
66

7-
use aquatic_udp_protocol::AnnounceEvent;
87
use axum::extract::State;
98
use axum::response::{IntoResponse, Response};
109
use bittorrent_http_tracker_core::services::announce::HttpAnnounceError;
11-
use bittorrent_http_tracker_protocol::v1::requests::announce::{Announce, Compact, Event};
10+
use bittorrent_http_tracker_protocol::v1::requests::announce::{Announce, Compact};
1211
use bittorrent_http_tracker_protocol::v1::responses::{self};
1312
use bittorrent_http_tracker_protocol::v1::services::peer_ip_resolver::ClientIpSources;
1413
use bittorrent_tracker_core::announce_handler::AnnounceHandler;
@@ -158,30 +157,6 @@ fn build_response(announce_request: &Announce, announce_data: AnnounceData) -> R
158157
}
159158
}
160159

161-
#[must_use]
162-
pub fn map_to_aquatic_event(event: &Option<Event>) -> aquatic_udp_protocol::AnnounceEvent {
163-
match event {
164-
Some(event) => match &event {
165-
Event::Started => aquatic_udp_protocol::AnnounceEvent::Started,
166-
Event::Stopped => aquatic_udp_protocol::AnnounceEvent::Stopped,
167-
Event::Completed => aquatic_udp_protocol::AnnounceEvent::Completed,
168-
},
169-
None => aquatic_udp_protocol::AnnounceEvent::None,
170-
}
171-
}
172-
173-
#[must_use]
174-
pub fn map_to_torrust_event(event: &Option<Event>) -> AnnounceEvent {
175-
match event {
176-
Some(event) => match &event {
177-
Event::Started => AnnounceEvent::Started,
178-
Event::Stopped => AnnounceEvent::Stopped,
179-
Event::Completed => AnnounceEvent::Completed,
180-
},
181-
None => AnnounceEvent::None,
182-
}
183-
}
184-
185160
#[cfg(test)]
186161
mod tests {
187162

‎packages/http-protocol/src/v1/requests/announce.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ pub fn peer_from_request(announce_request: &Announce, peer_ip: &IpAddr) -> peer:
399399
uploaded: announce_request.uploaded.unwrap_or(NumberOfBytes::new(0)),
400400
downloaded: announce_request.downloaded.unwrap_or(NumberOfBytes::new(0)),
401401
left: announce_request.left.unwrap_or(NumberOfBytes::new(0)),
402-
event: map_to_torrust_event(&announce_request.event),
402+
event: convert_to_aquatic_event(&announce_request.event),
403403
}
404404
}
405405

406406
#[must_use]
407-
pub fn map_to_torrust_event(event: &Option<Event>) -> AnnounceEvent {
407+
pub fn convert_to_aquatic_event(event: &Option<Event>) -> aquatic_udp_protocol::request::AnnounceEvent {
408408
match event {
409409
Some(event) => match &event {
410410
Event::Started => AnnounceEvent::Started,
@@ -444,7 +444,7 @@ mod tests {
444444
assert_eq!(
445445
announce_request,
446446
Announce {
447-
info_hash: "3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0".parse::<InfoHash>().unwrap(),
447+
info_hash: "3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0".parse::<InfoHash>().unwrap(), // DevSkim: ignore DS173237
448448
peer_id: PeerId(*b"-qB00000000000000001"),
449449
port: 17548,
450450
downloaded: None,
@@ -479,7 +479,7 @@ mod tests {
479479
assert_eq!(
480480
announce_request,
481481
Announce {
482-
info_hash: "3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0".parse::<InfoHash>().unwrap(),
482+
info_hash: "3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0".parse::<InfoHash>().unwrap(), // DevSkim: ignore DS173237
483483
peer_id: PeerId(*b"-qB00000000000000001"),
484484
port: 17548,
485485
downloaded: Some(NumberOfBytes::new(1)),

0 commit comments

Comments
 (0)
Please sign in to comment.