Swarm Dial taking forever #2579
-
|
Hello, I was wondering if someone could explain as to why this code causes the swarm dial to take upwards of 30s. SwarmBuilder::new(transport, behaviour, local_peer_id)
.executor(Box::new(|fut| block_on(fut)))
.build()as opposed to this which connects to the dialed peer within ms of dialing. Note: both peer on the same local network Swarm::new(transport, behaviour, local_peer_id)and here's where I'm dialing from if matches.value_of("connect").is_some() {
let addr: Multiaddr = matches.value_of("connect").unwrap().parse().unwrap();
if let Err(e) = swarm.dial(addr) {
println!("Publish error: {:?}", e);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This will block the whole thread until the See https://docs.rs/futures/latest/futures/executor/fn.block_on.html for details. |
Beta Was this translation helpful? Give feedback.
This will block the whole thread until the
futis resolved. Thus nothing withinSwarm(everything on the current thread) can make progress in the meantime. I am surprised this works at all (within 30s). I would expect it to deadlock.See https://docs.rs/futures/latest/futures/executor/fn.block_on.html for details.