@@ -4,14 +4,14 @@ use std::time::Duration;
44use aquatic_udp_protocol:: AnnounceEvent ;
55use serde:: { Deserialize , Serialize } ;
66
7- use super :: peer:: TorrentPeer ;
7+ use super :: peer;
88use crate :: protocol:: clock:: { Current , TimeNow } ;
99use crate :: protocol:: common:: { PeerId , MAX_SCRAPE_TORRENTS } ;
1010
1111#[ derive( Serialize , Deserialize , Clone , Debug ) ]
1212pub struct TorrentEntry {
1313 #[ serde( skip) ]
14- pub peers : std:: collections:: BTreeMap < PeerId , TorrentPeer > ,
14+ pub peers : std:: collections:: BTreeMap < PeerId , peer :: TorrentPeer > ,
1515 pub completed : u32 ,
1616}
1717
@@ -25,7 +25,7 @@ impl TorrentEntry {
2525 }
2626
2727 // Update peer and return completed (times torrent has been downloaded)
28- pub fn update_peer ( & mut self , peer : & TorrentPeer ) -> bool {
28+ pub fn update_peer ( & mut self , peer : & peer :: TorrentPeer ) -> bool {
2929 let mut did_torrent_stats_change: bool = false ;
3030
3131 match peer. event {
@@ -49,7 +49,7 @@ impl TorrentEntry {
4949 }
5050
5151 #[ must_use]
52- pub fn get_peers ( & self , client_addr : Option < & SocketAddr > ) -> Vec < & TorrentPeer > {
52+ pub fn get_peers ( & self , client_addr : Option < & SocketAddr > ) -> Vec < & peer :: TorrentPeer > {
5353 self . peers
5454 . values ( )
5555 . filter ( |peer| match client_addr {
@@ -118,16 +118,16 @@ mod tests {
118118
119119 use crate :: protocol:: clock:: { Current , DurationSinceUnixEpoch , Stopped , StoppedTime , Time , Working } ;
120120 use crate :: protocol:: common:: PeerId ;
121- use crate :: tracker:: peer:: TorrentPeer ;
121+ use crate :: tracker:: peer;
122122 use crate :: tracker:: torrent:: TorrentEntry ;
123123
124124 struct TorrentPeerBuilder {
125- peer : TorrentPeer ,
125+ peer : peer :: TorrentPeer ,
126126 }
127127
128128 impl TorrentPeerBuilder {
129129 pub fn default ( ) -> TorrentPeerBuilder {
130- let default_peer = TorrentPeer {
130+ let default_peer = peer :: TorrentPeer {
131131 peer_id : PeerId ( [ 0u8 ; 20 ] ) ,
132132 peer_addr : SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) , 8080 ) ,
133133 updated : Current :: now ( ) ,
@@ -164,14 +164,14 @@ mod tests {
164164 self
165165 }
166166
167- pub fn into ( self ) -> TorrentPeer {
167+ pub fn into ( self ) -> peer :: TorrentPeer {
168168 self . peer
169169 }
170170 }
171171
172172 /// A torrent seeder is a peer with 0 bytes left to download which
173173 /// has not announced it has stopped
174- fn a_torrent_seeder ( ) -> TorrentPeer {
174+ fn a_torrent_seeder ( ) -> peer :: TorrentPeer {
175175 TorrentPeerBuilder :: default ( )
176176 . with_number_of_bytes_left ( 0 )
177177 . with_event_completed ( )
@@ -180,7 +180,7 @@ mod tests {
180180
181181 /// A torrent leecher is a peer that is not a seeder.
182182 /// Leecher: left > 0 OR event = Stopped
183- fn a_torrent_leecher ( ) -> TorrentPeer {
183+ fn a_torrent_leecher ( ) -> peer :: TorrentPeer {
184184 TorrentPeerBuilder :: default ( )
185185 . with_number_of_bytes_left ( 1 )
186186 . with_event_completed ( )
0 commit comments