Skip to content

Commit

Permalink
dial always
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeguglielmo committed Nov 23, 2023
1 parent 719ee76 commit acd1099
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dht-cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async-trait = "0.1.68"
futures = "0.3.21"
futures-util = "0.3.29"
jsonpath_lib = "0.3.0"
libp2p = { version="0.53.1", features = ["tokio", "mdns", "gossipsub", "noise", "ping", "yamux", "pnet", "rsa", "tcp", "macros"] }
libp2p = { git="https://github.com/libp2p/rust-libp2p.git", rev = "add1ff6e50b335f2c8cacdb9e0f4dba90ad22f3b" ,features = ["tokio", "mdns", "gossipsub", "noise", "ping", "yamux", "pnet", "rsa", "tcp", "macros"] }
log = "0.4.17"
rand = "0.8"
sea-query = "0.28.3"
Expand Down
7 changes: 5 additions & 2 deletions dht-cache/src/domocache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use time::OffsetDateTime;
use tokio::sync::mpsc;
use tokio::sync::mpsc::{Receiver, Sender};
use crate::utils::get_epoch_ms;
use libp2p::swarm::dial_opts::DialOpts;
use libp2p::swarm::dial_opts::{DialOpts, PeerCondition};

fn generate_rsa_key() -> (Vec<u8>, Vec<u8>) {
let mut rng = rand::thread_rng();
Expand Down Expand Up @@ -477,7 +477,10 @@ impl DomoCache {
continue;
}

let dial_opts = DialOpts::from(peer_id);
let dial_opts = DialOpts::peer_id(peer_id)
.condition(PeerCondition::Always)
.build();

let _res = self.swarm.dial(dial_opts);
println!("INSERT INTO MDNS CACHE {} {} ", peer_id.to_string(), get_epoch_ms()/1000);

Expand Down
2 changes: 1 addition & 1 deletion dht-cache/src/domolibp2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub async fn start(
Ok(behaviour)

})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(1)))
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(10)))
.build();


Expand Down

0 comments on commit acd1099

Please sign in to comment.