@@ -111,7 +111,7 @@ impl AnnounceHandler {
111111pub enum PeersWanted {
112112 /// The peer wants as many peers as possible in the announce response.
113113 #[ default]
114- All ,
114+ AsManyAsPossible ,
115115 /// The peer only wants a certain amount of peers in the announce response.
116116 Only { amount : usize } ,
117117}
@@ -124,7 +124,7 @@ impl PeersWanted {
124124
125125 fn limit ( & self ) -> usize {
126126 match self {
127- PeersWanted :: All => TORRENT_PEERS_LIMIT ,
127+ PeersWanted :: AsManyAsPossible => TORRENT_PEERS_LIMIT ,
128128 PeersWanted :: Only { amount } => * amount,
129129 }
130130 }
@@ -133,7 +133,7 @@ impl PeersWanted {
133133impl From < i32 > for PeersWanted {
134134 fn from ( value : i32 ) -> Self {
135135 if value <= 0 {
136- return PeersWanted :: All ;
136+ return PeersWanted :: AsManyAsPossible ;
137137 }
138138
139139 // This conversion is safe because `value > 0`
@@ -148,7 +148,7 @@ impl From<i32> for PeersWanted {
148148impl From < u32 > for PeersWanted {
149149 fn from ( value : u32 ) -> Self {
150150 if value == 0 {
151- return PeersWanted :: All ;
151+ return PeersWanted :: AsManyAsPossible ;
152152 }
153153
154154 let amount = value as usize ;
@@ -350,7 +350,8 @@ mod tests {
350350
351351 let mut peer = sample_peer ( ) ;
352352
353- let announce_data = announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: All ) ;
353+ let announce_data =
354+ announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: AsManyAsPossible ) ;
354355
355356 assert_eq ! ( announce_data. peers, vec![ ] ) ;
356357 }
@@ -364,11 +365,12 @@ mod tests {
364365 & sample_info_hash ( ) ,
365366 & mut previously_announced_peer,
366367 & peer_ip ( ) ,
367- & PeersWanted :: All ,
368+ & PeersWanted :: AsManyAsPossible ,
368369 ) ;
369370
370371 let mut peer = sample_peer_2 ( ) ;
371- let announce_data = announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: All ) ;
372+ let announce_data =
373+ announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: AsManyAsPossible ) ;
372374
373375 assert_eq ! ( announce_data. peers, vec![ Arc :: new( previously_announced_peer) ] ) ;
374376 }
@@ -382,15 +384,15 @@ mod tests {
382384 & sample_info_hash ( ) ,
383385 & mut previously_announced_peer_1,
384386 & peer_ip ( ) ,
385- & PeersWanted :: All ,
387+ & PeersWanted :: AsManyAsPossible ,
386388 ) ;
387389
388390 let mut previously_announced_peer_2 = sample_peer_2 ( ) ;
389391 announce_handler. announce (
390392 & sample_info_hash ( ) ,
391393 & mut previously_announced_peer_2,
392394 & peer_ip ( ) ,
393- & PeersWanted :: All ,
395+ & PeersWanted :: AsManyAsPossible ,
394396 ) ;
395397
396398 let mut peer = sample_peer_3 ( ) ;
@@ -418,7 +420,7 @@ mod tests {
418420 let mut peer = seeder ( ) ;
419421
420422 let announce_data =
421- announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: All ) ;
423+ announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: AsManyAsPossible ) ;
422424
423425 assert_eq ! ( announce_data. stats. complete, 1 ) ;
424426 }
@@ -430,7 +432,7 @@ mod tests {
430432 let mut peer = leecher ( ) ;
431433
432434 let announce_data =
433- announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: All ) ;
435+ announce_handler. announce ( & sample_info_hash ( ) , & mut peer, & peer_ip ( ) , & PeersWanted :: AsManyAsPossible ) ;
434436
435437 assert_eq ! ( announce_data. stats. incomplete, 1 ) ;
436438 }
@@ -441,11 +443,20 @@ mod tests {
441443
442444 // We have to announce with "started" event because peer does not count if peer was not previously known
443445 let mut started_peer = started_peer ( ) ;
444- announce_handler. announce ( & sample_info_hash ( ) , & mut started_peer, & peer_ip ( ) , & PeersWanted :: All ) ;
446+ announce_handler. announce (
447+ & sample_info_hash ( ) ,
448+ & mut started_peer,
449+ & peer_ip ( ) ,
450+ & PeersWanted :: AsManyAsPossible ,
451+ ) ;
445452
446453 let mut completed_peer = completed_peer ( ) ;
447- let announce_data =
448- announce_handler. announce ( & sample_info_hash ( ) , & mut completed_peer, & peer_ip ( ) , & PeersWanted :: All ) ;
454+ let announce_data = announce_handler. announce (
455+ & sample_info_hash ( ) ,
456+ & mut completed_peer,
457+ & peer_ip ( ) ,
458+ & PeersWanted :: AsManyAsPossible ,
459+ ) ;
449460
450461 assert_eq ! ( announce_data. stats. downloaded, 1 ) ;
451462 }
@@ -494,11 +505,11 @@ mod tests {
494505 let mut peer = sample_peer ( ) ;
495506
496507 peer. event = AnnounceEvent :: Started ;
497- let announce_data = announce_handler. announce ( & info_hash, & mut peer, & peer_ip ( ) , & PeersWanted :: All ) ;
508+ let announce_data = announce_handler. announce ( & info_hash, & mut peer, & peer_ip ( ) , & PeersWanted :: AsManyAsPossible ) ;
498509 assert_eq ! ( announce_data. stats. downloaded, 0 ) ;
499510
500511 peer. event = AnnounceEvent :: Completed ;
501- let announce_data = announce_handler. announce ( & info_hash, & mut peer, & peer_ip ( ) , & PeersWanted :: All ) ;
512+ let announce_data = announce_handler. announce ( & info_hash, & mut peer, & peer_ip ( ) , & PeersWanted :: AsManyAsPossible ) ;
502513 assert_eq ! ( announce_data. stats. downloaded, 1 ) ;
503514
504515 // Remove the newly updated torrent from memory
@@ -533,7 +544,7 @@ mod tests {
533544
534545 #[ test]
535546 fn it_should_return_74_at_the_most_if_the_client_wants_them_all ( ) {
536- let peers_wanted = PeersWanted :: All ;
547+ let peers_wanted = PeersWanted :: AsManyAsPossible ;
537548
538549 assert_eq ! ( peers_wanted. limit( ) , TORRENT_PEERS_LIMIT ) ;
539550 }
0 commit comments