Skip to content

Commit 002af00

Browse files
authored
imp(orchestrator): p2p relay setup (#474)
* setup p2p relay
1 parent ae4b38c commit 002af00

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

crates/orchestrator/src/p2p/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl P2PClient {
6161
worker_addresses,
6262
worker_wallet_address,
6363
P2PMessage::GetTaskLogs,
64-
15, // 15 second timeout for getting logs
64+
20,
6565
)
6666
.await?;
6767

crates/shared/src/p2p/client.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use alloy::primitives::Address;
22
use anyhow::Result;
33
use iroh::endpoint::{RecvStream, SendStream};
4-
use iroh::{Endpoint, NodeAddr, NodeId, SecretKey};
4+
use iroh::{Endpoint, NodeAddr, NodeId, RelayMode, SecretKey};
55
use log::{debug, info};
66
use std::str::FromStr;
77
use std::time::Duration;
@@ -28,6 +28,7 @@ impl P2PClient {
2828
let endpoint = Endpoint::builder()
2929
.secret_key(secret_key)
3030
.alpns(vec![PRIME_P2P_PROTOCOL.to_vec()])
31+
.relay_mode(RelayMode::Default)
3132
.discovery_n0()
3233
.bind()
3334
.await?;
@@ -219,8 +220,6 @@ impl P2PClient {
219220
// Read response
220221
let response: P2PResponse = Self::read_message(&mut recv).await?;
221222

222-
// Close connection
223-
connection.close(0u32.into(), b"request complete");
224223
tokio::time::sleep(Duration::from_millis(50)).await;
225224

226225
Ok(response.message)

crates/worker/src/p2p/service.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use alloy::primitives::{Address, FixedBytes, U256};
66
use anyhow::Result;
77
use dashmap::DashMap;
88
use iroh::endpoint::Incoming;
9-
use iroh::{Endpoint, SecretKey};
9+
use iroh::{Endpoint, RelayMode, SecretKey};
1010
use lazy_static::lazy_static;
1111
use log::{debug, error, info, warn};
1212
use rand_v8::Rng;
@@ -77,6 +77,7 @@ impl P2PService {
7777
.secret_key(secret_key)
7878
.alpns(vec![PRIME_P2P_PROTOCOL.to_vec()])
7979
.discovery_n0()
80+
.relay_mode(RelayMode::Default)
8081
.bind()
8182
.await?;
8283

@@ -158,9 +159,6 @@ impl P2PService {
158159
}
159160
// Wait a bit before closing to ensure client has processed response
160161
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
161-
162-
// Properly close the connection after handling the stream
163-
connection.close(0u32.into(), b"stream complete");
164162
}
165163
Err(e) => {
166164
error!("Failed to accept bi-stream: {}", e);

0 commit comments

Comments
 (0)