Use concrete type for DHT peers

This commit is contained in:
Igor Katson 2023-11-30 08:06:55 +00:00
parent 6243c5f02f
commit 210a3d5d3e
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
4 changed files with 15 additions and 14 deletions

View file

@ -145,7 +145,7 @@ struct RecursiveRequest<C: RecursiveRequestCallbacks> {
callbacks: C,
}
struct RequestPeersStream {
pub struct RequestPeersStream {
rx: tokio::sync::mpsc::UnboundedReceiver<SocketAddr>,
cancel_join_handle: tokio::task::JoinHandle<()>,
}
@ -959,10 +959,7 @@ impl DhtState {
Ok(state)
}
pub fn get_peers(
self: &Arc<Self>,
info_hash: Id20,
) -> anyhow::Result<impl Stream<Item = SocketAddr> + Unpin> {
pub fn get_peers(self: &Arc<Self>, info_hash: Id20) -> anyhow::Result<RequestPeersStream> {
Ok(RequestPeersStream::new(self.clone(), info_hash))
}

View file

@ -8,7 +8,7 @@ use std::sync::Arc;
use std::time::Duration;
pub use crate::dht::DhtStats;
pub use crate::dht::{DhtConfig, DhtState};
pub use crate::dht::{DhtConfig, DhtState, RequestPeersStream};
pub use librqbit_core::id20::Id20;
pub use persistence::{PersistentDht, PersistentDhtConfig};