11use std:: sync:: Arc ;
22
33use torrust_tracker_configuration:: Core ;
4+ use torrust_tracker_torrent_repository:: container:: TorrentRepositoryContainer ;
5+ use torrust_tracker_torrent_repository:: Swarms ;
46
57use crate :: announce_handler:: AnnounceHandler ;
68use crate :: authentication:: handler:: KeysHandler ;
@@ -35,8 +37,19 @@ pub struct TrackerCoreContainer {
3537}
3638
3739impl TrackerCoreContainer {
40+ #[ must_use]
41+ pub fn initialize_from ( core_config : & Arc < Core > , torrent_repository_container : & Arc < TorrentRepositoryContainer > ) -> Self {
42+ Self :: inner_initialize ( core_config, & torrent_repository_container. swarms )
43+ }
44+
3845 #[ must_use]
3946 pub fn initialize ( core_config : & Arc < Core > ) -> Self {
47+ let swarms = Arc :: new ( Swarms :: default ( ) ) ;
48+ Self :: inner_initialize ( core_config, & swarms)
49+ }
50+
51+ #[ must_use]
52+ fn inner_initialize ( core_config : & Arc < Core > , swarms : & Arc < Swarms > ) -> Self {
4053 let database = initialize_database ( core_config) ;
4154 let in_memory_whitelist = Arc :: new ( InMemoryWhitelist :: default ( ) ) ;
4255 let whitelist_authorization = Arc :: new ( WhitelistAuthorization :: new ( core_config, & in_memory_whitelist. clone ( ) ) ) ;
@@ -48,7 +61,7 @@ impl TrackerCoreContainer {
4861 & db_key_repository. clone ( ) ,
4962 & in_memory_key_repository. clone ( ) ,
5063 ) ) ;
51- let in_memory_torrent_repository = Arc :: new ( InMemoryTorrentRepository :: default ( ) ) ;
64+ let in_memory_torrent_repository = Arc :: new ( InMemoryTorrentRepository :: new ( swarms . clone ( ) ) ) ;
5265 let db_torrent_repository = Arc :: new ( DatabasePersistentTorrentRepository :: new ( & database) ) ;
5366
5467 let torrents_manager = Arc :: new ( TorrentsManager :: new (
0 commit comments