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(()) }