Deentangled classes a bit

This commit is contained in:
Igor Katson 2021-07-03 12:44:21 +01:00
parent 85e33741b7
commit 0e80ad3254

View file

@ -1,6 +1,7 @@
use std::{ use std::{
collections::HashSet, collections::HashSet,
fs::{File, OpenOptions}, fs::{File, OpenOptions},
net::SocketAddr,
ops::Deref, ops::Deref,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::{ sync::{
@ -11,14 +12,13 @@ use std::{
}; };
use anyhow::Context; use anyhow::Context;
use futures::{stream::FuturesUnordered, StreamExt}; use log::{debug, info};
use log::{debug, info, warn};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use reqwest::Url; use reqwest::Url;
use size_format::SizeFormatterBinary as SF; use size_format::SizeFormatterBinary as SF;
use crate::{ use crate::{
buffers::{ByteBuf, ByteString}, buffers::ByteString,
chunk_tracker::ChunkTracker, chunk_tracker::ChunkTracker,
file_ops::FileOps, file_ops::FileOps,
http_api::make_and_run_http_api, http_api::make_and_run_http_api,
@ -26,7 +26,7 @@ use crate::{
peer_id::generate_peer_id, peer_id::generate_peer_id,
spawn_utils::{spawn, BlockingSpawner}, spawn_utils::{spawn, BlockingSpawner},
speed_estimator::SpeedEstimator, speed_estimator::SpeedEstimator,
torrent_metainfo::{TorrentMetaV1Info, TorrentMetaV1Owned}, torrent_metainfo::TorrentMetaV1Info,
torrent_state::{AtomicStats, TorrentState, TorrentStateLocked}, torrent_state::{AtomicStats, TorrentState, TorrentStateLocked},
tracker_comms::{TrackerError, TrackerRequest, TrackerRequestEvent, TrackerResponse}, tracker_comms::{TrackerError, TrackerRequest, TrackerRequestEvent, TrackerResponse},
type_aliases::Sha1, type_aliases::Sha1,
@ -108,6 +108,9 @@ impl TorrentManagerHandle {
false 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<()> { pub async fn cancel(&self) -> anyhow::Result<()> {
todo!() todo!()
} }