Skip to content

Commit

Permalink
chore: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Dec 1, 2024
1 parent 8f2edf6 commit 2c71d00
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions extensions/warp-ipfs/src/store/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ use super::{protocols, DidExt, PeerIdExt, PeerType};
use crate::config::{Discovery as DiscoveryConfig, DiscoveryType};
use crate::store::payload::{PayloadBuilder, PayloadMessage};

//TODO: Deprecate for separate discovery service

#[allow(dead_code)]
#[derive(Clone)]
pub struct Discovery {
ipfs: Ipfs,
Expand Down Expand Up @@ -482,7 +479,7 @@ impl Stream for DiscoveryPeerTask {
}
}
Err(e) => {
// TODO: probably close connection
// TODO: probably close connection?
self.ping_timer = Some(Delay::new(Duration::from_secs(60)));
tracing::error!(error = %e, peer_id = ?self.peer_id, "pinging failed");
}
Expand Down Expand Up @@ -562,7 +559,7 @@ enum DiscoveryResponse {

impl DiscoveryTask {
#[allow(dead_code)]
pub fn discover_initial_peers(&mut self, ns: Option<String>) {
pub fn discovery(&mut self, ns: Option<String>) {
match self.config {
DiscoveryConfig::Shuttle { .. } => {}
DiscoveryConfig::Namespace {
Expand All @@ -584,6 +581,7 @@ impl DiscoveryTask {
.collect::<IndexSet<_>>();

if !peers.is_empty() {
// We will use the first instance instead of the whole set for now
let peer_id = peers.get_index(0).copied().expect("should not fail");
self.rz_discovery(namespace, peer_id);
}
Expand All @@ -594,7 +592,6 @@ impl DiscoveryTask {
}
}

#[allow(dead_code)]
pub fn dht_discovery(&mut self, namespace: String) {
if self.discovery_fut.is_some() {
return;
Expand All @@ -604,15 +601,14 @@ impl DiscoveryTask {
let bytes = namespace.as_bytes();
let stream = ipfs.dht_get_providers(bytes.to_vec()).await?;
// We collect instead of passing the stream through and polling there is to try to maintain compatibility in discovery
// Note: This may change in the future where we would focus on a single discovery method
// Note: This may change in the future where we would focus on a single discovery method (ie shuttle)
let peers = stream.collect::<IndexSet<_>>().await;
Ok::<_, Error>(Vec::from_iter(peers))
};

self.discovery_fut.replace(Box::pin(fut));
}

#[allow(dead_code)]
pub fn rz_discovery(&mut self, namespace: String, rz_peer_id: PeerId) {
if self.discovery_fut.is_some() {
return;
Expand Down

0 comments on commit 2c71d00

Please sign in to comment.