@@ -22,55 +22,6 @@ use torrust_tracker_primitives::core::ScrapeData;
22
22
23
23
use crate :: statistics;
24
24
25
- /// Errors related to announce requests.
26
- #[ derive( thiserror:: Error , Debug , Clone ) ]
27
- pub enum HttpScrapeError {
28
- #[ error( "Error resolving peer IP: {source}" ) ]
29
- PeerIpResolutionError { source : PeerIpResolutionError } ,
30
-
31
- #[ error( "Tracker core error: {source}" ) ]
32
- TrackerCoreError { source : TrackerCoreError } ,
33
- }
34
-
35
- impl From < PeerIpResolutionError > for HttpScrapeError {
36
- fn from ( peer_ip_resolution_error : PeerIpResolutionError ) -> Self {
37
- Self :: PeerIpResolutionError {
38
- source : peer_ip_resolution_error,
39
- }
40
- }
41
- }
42
-
43
- impl From < TrackerCoreError > for HttpScrapeError {
44
- fn from ( tracker_core_error : TrackerCoreError ) -> Self {
45
- Self :: TrackerCoreError {
46
- source : tracker_core_error,
47
- }
48
- }
49
- }
50
-
51
- impl From < ScrapeError > for HttpScrapeError {
52
- fn from ( announce_error : ScrapeError ) -> Self {
53
- Self :: TrackerCoreError {
54
- source : announce_error. into ( ) ,
55
- }
56
- }
57
- }
58
-
59
- impl From < WhitelistError > for HttpScrapeError {
60
- fn from ( whitelist_error : WhitelistError ) -> Self {
61
- Self :: TrackerCoreError {
62
- source : whitelist_error. into ( ) ,
63
- }
64
- }
65
- }
66
-
67
- impl From < authentication:: key:: Error > for HttpScrapeError {
68
- fn from ( whitelist_error : authentication:: key:: Error ) -> Self {
69
- Self :: TrackerCoreError {
70
- source : whitelist_error. into ( ) ,
71
- }
72
- }
73
- }
74
25
/// The HTTP tracker `scrape` service.
75
26
///
76
27
/// The service sends an statistics event that increments:
@@ -110,6 +61,8 @@ impl ScrapeService {
110
61
}
111
62
}
112
63
64
+ /// Handles a scrape request.
65
+ ///
113
66
/// # Errors
114
67
///
115
68
/// This function will return an error if:
@@ -186,6 +139,56 @@ async fn send_scrape_event(
186
139
}
187
140
}
188
141
142
+ /// Errors related to announce requests.
143
+ #[ derive( thiserror:: Error , Debug , Clone ) ]
144
+ pub enum HttpScrapeError {
145
+ #[ error( "Error resolving peer IP: {source}" ) ]
146
+ PeerIpResolutionError { source : PeerIpResolutionError } ,
147
+
148
+ #[ error( "Tracker core error: {source}" ) ]
149
+ TrackerCoreError { source : TrackerCoreError } ,
150
+ }
151
+
152
+ impl From < PeerIpResolutionError > for HttpScrapeError {
153
+ fn from ( peer_ip_resolution_error : PeerIpResolutionError ) -> Self {
154
+ Self :: PeerIpResolutionError {
155
+ source : peer_ip_resolution_error,
156
+ }
157
+ }
158
+ }
159
+
160
+ impl From < TrackerCoreError > for HttpScrapeError {
161
+ fn from ( tracker_core_error : TrackerCoreError ) -> Self {
162
+ Self :: TrackerCoreError {
163
+ source : tracker_core_error,
164
+ }
165
+ }
166
+ }
167
+
168
+ impl From < ScrapeError > for HttpScrapeError {
169
+ fn from ( announce_error : ScrapeError ) -> Self {
170
+ Self :: TrackerCoreError {
171
+ source : announce_error. into ( ) ,
172
+ }
173
+ }
174
+ }
175
+
176
+ impl From < WhitelistError > for HttpScrapeError {
177
+ fn from ( whitelist_error : WhitelistError ) -> Self {
178
+ Self :: TrackerCoreError {
179
+ source : whitelist_error. into ( ) ,
180
+ }
181
+ }
182
+ }
183
+
184
+ impl From < authentication:: key:: Error > for HttpScrapeError {
185
+ fn from ( whitelist_error : authentication:: key:: Error ) -> Self {
186
+ Self :: TrackerCoreError {
187
+ source : whitelist_error. into ( ) ,
188
+ }
189
+ }
190
+ }
191
+
189
192
#[ cfg( test) ]
190
193
mod tests {
191
194
0 commit comments