From 96946d5a818c01f9d8596fe2d4608a44b8c34289 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Thu, 5 Dec 2024 21:57:44 +0000 Subject: [PATCH] "make_peer_rx_managed_torrent" --- crates/librqbit/src/session.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index 5f6b2c6..d2e0578 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -1330,6 +1330,21 @@ impl Session { Ok(()) } + pub fn make_peer_rx_managed_torrent( + self: &Arc, + t: &Arc, + announce: bool, + ) -> anyhow::Result { + self.make_peer_rx( + t.info_hash(), + t.shared().trackers.iter().cloned().collect(), + announce, + t.shared().options.force_tracker_interval, + t.shared().options.initial_peers.clone(), + )? + .context("no peer source") + } + // Get a peer stream from both DHT and trackers. fn make_peer_rx( self: &Arc, @@ -1387,14 +1402,8 @@ impl Session { } pub async fn unpause(self: &Arc, handle: &ManagedTorrentHandle) -> anyhow::Result<()> { - let peer_rx = self.make_peer_rx( - handle.info_hash(), - handle.shared().trackers.clone().into_iter().collect(), - true, - handle.shared().options.force_tracker_interval, - handle.shared().options.initial_peers.clone(), - )?; - handle.start(peer_rx, false)?; + let peer_rx = self.make_peer_rx_managed_torrent(handle, true)?; + handle.start(Some(peer_rx), false)?; self.try_update_persistence_metadata(handle).await; Ok(()) }