@@ -487,7 +487,7 @@ pub struct Tracker {
487
487
pub whitelist_authorization : Arc < whitelist:: authorization:: Authorization > ,
488
488
489
489
/// The in-memory torrents repository.
490
- torrents : Arc < InMemoryTorrentRepository > ,
490
+ in_memory_torrent_repository : Arc < InMemoryTorrentRepository > ,
491
491
492
492
/// The persistent torrents repository.
493
493
db_torrent_repository : Arc < DatabasePersistentTorrentRepository > ,
@@ -550,7 +550,7 @@ impl Tracker {
550
550
config : config. clone ( ) ,
551
551
database : database. clone ( ) ,
552
552
whitelist_authorization : whitelist_authorization. clone ( ) ,
553
- torrents : Arc :: new ( InMemoryTorrentRepository :: default ( ) ) ,
553
+ in_memory_torrent_repository : Arc :: new ( InMemoryTorrentRepository :: default ( ) ) ,
554
554
db_torrent_repository : Arc :: new ( DatabasePersistentTorrentRepository :: new ( database) ) ,
555
555
} )
556
556
}
@@ -658,7 +658,7 @@ impl Tracker {
658
658
659
659
/// It returns the data for a `scrape` response.
660
660
fn get_swarm_metadata ( & self , info_hash : & InfoHash ) -> SwarmMetadata {
661
- self . torrents . get_swarm_metadata ( info_hash)
661
+ self . in_memory_torrent_repository . get_swarm_metadata ( info_hash)
662
662
}
663
663
664
664
/// It loads the torrents from database into memory. It only loads the torrent entry list with the number of seeders for each torrent.
@@ -672,7 +672,7 @@ impl Tracker {
672
672
pub fn load_torrents_from_database ( & self ) -> Result < ( ) , databases:: error:: Error > {
673
673
let persistent_torrents = self . db_torrent_repository . load_all ( ) ?;
674
674
675
- self . torrents . import_persistent ( & persistent_torrents) ;
675
+ self . in_memory_torrent_repository . import_persistent ( & persistent_torrents) ;
676
676
677
677
Ok ( ( ) )
678
678
}
@@ -683,15 +683,15 @@ impl Tracker {
683
683
///
684
684
/// It filters out the client making the request.
685
685
fn get_peers_for ( & self , info_hash : & InfoHash , peer : & peer:: Peer , limit : usize ) -> Vec < Arc < peer:: Peer > > {
686
- self . torrents . get_peers_for ( info_hash, peer, limit)
686
+ self . in_memory_torrent_repository . get_peers_for ( info_hash, peer, limit)
687
687
}
688
688
689
689
/// # Context: Tracker
690
690
///
691
691
/// Get torrent peers for a given torrent.
692
692
#[ must_use]
693
693
pub fn get_torrent_peers ( & self , info_hash : & InfoHash ) -> Vec < Arc < peer:: Peer > > {
694
- self . torrents . get_torrent_peers ( info_hash)
694
+ self . in_memory_torrent_repository . get_torrent_peers ( info_hash)
695
695
}
696
696
697
697
/// It updates the torrent entry in memory, it also stores in the database
@@ -701,14 +701,14 @@ impl Tracker {
701
701
/// # Context: Tracker
702
702
#[ must_use]
703
703
pub fn upsert_peer_and_get_stats ( & self , info_hash : & InfoHash , peer : & peer:: Peer ) -> SwarmMetadata {
704
- let swarm_metadata_before = match self . torrents . get_opt_swarm_metadata ( info_hash) {
704
+ let swarm_metadata_before = match self . in_memory_torrent_repository . get_opt_swarm_metadata ( info_hash) {
705
705
Some ( swarm_metadata) => swarm_metadata,
706
706
None => SwarmMetadata :: zeroed ( ) ,
707
707
} ;
708
708
709
- self . torrents . upsert_peer ( info_hash, peer) ;
709
+ self . in_memory_torrent_repository . upsert_peer ( info_hash, peer) ;
710
710
711
- let swarm_metadata_after = match self . torrents . get_opt_swarm_metadata ( info_hash) {
711
+ let swarm_metadata_after = match self . in_memory_torrent_repository . get_opt_swarm_metadata ( info_hash) {
712
712
Some ( swarm_metadata) => swarm_metadata,
713
713
None => SwarmMetadata :: zeroed ( ) ,
714
714
} ;
@@ -741,7 +741,7 @@ impl Tracker {
741
741
/// Panics if unable to get the torrent metrics.
742
742
#[ must_use]
743
743
pub fn get_torrents_metrics ( & self ) -> TorrentsMetrics {
744
- self . torrents . get_torrents_metrics ( )
744
+ self . in_memory_torrent_repository . get_torrents_metrics ( )
745
745
}
746
746
747
747
/// Remove inactive peers and (optionally) peerless torrents.
@@ -751,10 +751,11 @@ impl Tracker {
751
751
let current_cutoff = CurrentClock :: now_sub ( & Duration :: from_secs ( u64:: from ( self . config . tracker_policy . max_peer_timeout ) ) )
752
752
. unwrap_or_default ( ) ;
753
753
754
- self . torrents . remove_inactive_peers ( current_cutoff) ;
754
+ self . in_memory_torrent_repository . remove_inactive_peers ( current_cutoff) ;
755
755
756
756
if self . config . tracker_policy . remove_peerless_torrents {
757
- self . torrents . remove_peerless_torrents ( & self . config . tracker_policy ) ;
757
+ self . in_memory_torrent_repository
758
+ . remove_peerless_torrents ( & self . config . tracker_policy ) ;
758
759
}
759
760
}
760
761
@@ -1505,11 +1506,14 @@ mod tests {
1505
1506
assert_eq ! ( swarm_stats. downloaded, 1 ) ;
1506
1507
1507
1508
// Remove the newly updated torrent from memory
1508
- let _unused = tracker. torrents . remove ( & info_hash) ;
1509
+ let _unused = tracker. in_memory_torrent_repository . remove ( & info_hash) ;
1509
1510
1510
1511
tracker. load_torrents_from_database ( ) . unwrap ( ) ;
1511
1512
1512
- let torrent_entry = tracker. torrents . get ( & info_hash) . expect ( "it should be able to get entry" ) ;
1513
+ let torrent_entry = tracker
1514
+ . in_memory_torrent_repository
1515
+ . get ( & info_hash)
1516
+ . expect ( "it should be able to get entry" ) ;
1513
1517
1514
1518
// It persists the number of completed peers.
1515
1519
assert_eq ! ( torrent_entry. get_swarm_metadata( ) . downloaded, 1 ) ;
0 commit comments