Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tracker/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::peer::TorrentPeer;
use crate::protocol::clock::clock::{DefaultClock, TimeNow};
use crate::{PeerId, MAX_SCRAPE_TORRENTS};

#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct TorrentEntry {
#[serde(skip)]
pub peers: std::collections::BTreeMap<PeerId, TorrentPeer>,
Expand Down
13 changes: 11 additions & 2 deletions src/tracker/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,20 @@ impl TorrentTracker {

// Adding torrents is not relevant to public trackers.
pub async fn add_torrent_to_whitelist(&self, info_hash: &InfoHash) -> Result<(), database::Error> {
self.database.add_info_hash_to_whitelist(info_hash.clone()).await?;
self.whitelist.write().await.insert(info_hash.clone());
self.add_torrent_to_database_whitelist(info_hash).await?;
self.add_torrent_to_memory_whitelist(info_hash).await;
Ok(())
}

async fn add_torrent_to_database_whitelist(&self, info_hash: &InfoHash) -> Result<(), database::Error> {
self.database.add_info_hash_to_whitelist(*info_hash).await?;
Ok(())
}

pub async fn add_torrent_to_memory_whitelist(&self, info_hash: &InfoHash) -> bool {
self.whitelist.write().await.insert(*info_hash)
}

// Removing torrents is not relevant to public trackers.
pub async fn remove_torrent_from_whitelist(&self, info_hash: &InfoHash) -> Result<(), database::Error> {
self.database.remove_info_hash_from_whitelist(info_hash.clone()).await?;
Expand Down
Loading