From 0e80ad3254b1b366bc256829dba47e91e5896473 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Sat, 3 Jul 2021 12:44:21 +0100 Subject: [PATCH] Deentangled classes a bit --- crates/librqbit/src/torrent_manager.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/librqbit/src/torrent_manager.rs b/crates/librqbit/src/torrent_manager.rs index ce9daea..5a63aec 100644 --- a/crates/librqbit/src/torrent_manager.rs +++ b/crates/librqbit/src/torrent_manager.rs @@ -1,6 +1,7 @@ use std::{ collections::HashSet, fs::{File, OpenOptions}, + net::SocketAddr, ops::Deref, path::{Path, PathBuf}, sync::{ @@ -11,14 +12,13 @@ use std::{ }; use anyhow::Context; -use futures::{stream::FuturesUnordered, StreamExt}; -use log::{debug, info, warn}; +use log::{debug, info}; use parking_lot::{Mutex, RwLock}; use reqwest::Url; use size_format::SizeFormatterBinary as SF; use crate::{ - buffers::{ByteBuf, ByteString}, + buffers::ByteString, chunk_tracker::ChunkTracker, file_ops::FileOps, http_api::make_and_run_http_api, @@ -26,7 +26,7 @@ use crate::{ peer_id::generate_peer_id, spawn_utils::{spawn, BlockingSpawner}, speed_estimator::SpeedEstimator, - torrent_metainfo::{TorrentMetaV1Info, TorrentMetaV1Owned}, + torrent_metainfo::TorrentMetaV1Info, torrent_state::{AtomicStats, TorrentState, TorrentStateLocked}, tracker_comms::{TrackerError, TrackerRequest, TrackerRequestEvent, TrackerResponse}, type_aliases::Sha1, @@ -108,6 +108,9 @@ impl TorrentManagerHandle { false } } + pub fn add_peer(&self, addr: SocketAddr) -> bool { + self.manager.state.add_peer_if_not_seen(addr) + } pub async fn cancel(&self) -> anyhow::Result<()> { todo!() }