Skip to content

Commit a0df334

Browse files
committed
Fix P2P discovery port mismatch with HTTP API endpoints
- Change target ports from 9876/9877 to 8001/9877 (actual API ports) - Fix region detection to use IP-based mapping instead of port-based - Ensure P2P discovery connects to real HTTP API endpoints - Resolve node isolation by testing correct service ports
1 parent 8f03949 commit a0df334

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

‎development/qnet-integration/src/unified_p2p.rs‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ impl SimplifiedP2P {
300300
}
301301

302302
println!("[P2P] 🌐 Attempting to connect to peer: {}", ip);
303-
// PRODUCTION FIX: All genesis nodes listen on both 9876 and 9877
304-
// Try both ports regardless of region for reliable discovery
305-
let target_ports = vec![9876, 9877];
303+
// PRODUCTION FIX: Test actual HTTP API ports where nodes listen
304+
// 8001 = primary API port, 9877 = RPC port
305+
let target_ports = vec![8001, 9877];
306306

307307
for target_port in target_ports {
308308
let target_addr = format!("{}:{}", ip, target_port);
@@ -315,16 +315,19 @@ impl SimplifiedP2P {
315315
Ok(Ok(_)) => {
316316
println!("🌟 [P2P] Quantum-secured connection established: {} | 🔐 Post-quantum encryption active", target_addr);
317317

318-
// Determine region based on IP and port
319-
let peer_region = match target_port {
320-
9876 => Region::NorthAmerica,
321-
9877 => Region::Europe,
322-
9878 => Region::Asia,
323-
9879 => Region::SouthAmerica,
324-
9880 => Region::Africa,
325-
9881 => Region::Oceania,
326-
_ => region.clone(),
327-
};
318+
// Determine region based on genesis node IP (not port)
319+
let peer_region = GENESIS_BOOTSTRAP_NODES.iter()
320+
.find(|(node_ip, _)| *node_ip == ip)
321+
.map(|(_, region_name)| match *region_name {
322+
"NorthAmerica" => Region::NorthAmerica,
323+
"Europe" => Region::Europe,
324+
"Asia" => Region::Asia,
325+
"SouthAmerica" => Region::SouthAmerica,
326+
"Africa" => Region::Africa,
327+
"Oceania" => Region::Oceania,
328+
_ => region.clone(),
329+
})
330+
.unwrap_or_else(|| region.clone());
328331

329332
let peer_info = PeerInfo {
330333
id: format!("genesis_{}", target_addr.replace(":", "_")),

0 commit comments

Comments
 (0)