Skip to content

Commit

Permalink
chore: Implement timeout on relay connection
Browse files Browse the repository at this point in the history
Note: This will change in the future to perform upstream
  • Loading branch information
dariusc93 committed Nov 13, 2023
1 parent f55f7d9 commit c7f8741
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions extensions/warp-ipfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,19 @@ impl WarpIpfs {
}

for relay_peer in relay_peers {
if let Err(e) = ipfs.enable_relay(Some(relay_peer)).await {
error!("Failed to use {relay_peer} as a relay: {e}");
continue;
}
match tokio::time::timeout(Duration::from_secs(15), ipfs.enable_relay(Some(relay_peer)))
.await
{
Ok(Ok(_)) => {}
Ok(Err(e)) => {
error!("Failed to use {relay_peer} as a relay: {e}");
continue;
}
Err(_) => {
error!("Relay connection timed out");
continue;
}
};

let list = ipfs.list_relays(true).await.unwrap_or_default();
for addr in list
Expand Down

0 comments on commit c7f8741

Please sign in to comment.