[TSM.ID].[11031972] 3Z SWEEP: Fix 7 modules — xcu-tui(unused HashMap), xcu-rpc(invalid hex 0xXC), xcu-ouroboros(unused HashMap), xcu-labyrinth(borrow checker), xcu-qcg-wasm(unused Arc/Mutex), xcu-watermark(unused var), xcu-thread-weaver(unused var). VERVAL 2x ALL CLEAN.

This commit is contained in:
TSM.ID
2026-05-25 08:26:54 +07:00
parent b51e8a45e0
commit c88689ff67
7 changed files with 14 additions and 9 deletions
+11 -3
View File
@@ -75,6 +75,13 @@ impl Labyrinth {
/// Select route through the labyrinth
pub fn build_route(&mut self, source: &str, destination: &str) -> Result<Vec<String>, LabyrinthError> {
// Pre-compute random values before borrowing self.nodes
let hop_rand = self.next_random();
let node_count = self.nodes.len();
let rand_scores: Vec<f64> = (0..node_count)
.map(|_| (self.next_random() % 100) as f64 * 0.3)
.collect();
let eligible: Vec<&LabyrinthNode> = self.nodes.values()
.filter(|n| n.is_alive)
.filter(|n| !self.avoid_countries.contains(&n.country))
@@ -85,15 +92,16 @@ impl Labyrinth {
return Err(LabyrinthError::NoRoute(format!("Need {} hops, only {} nodes", self.min_hops, eligible.len())));
}
let hop_count = self.min_hops + (self.next_random() as usize % (self.max_hops - self.min_hops + 1));
let hop_count = self.min_hops + (hop_rand as usize % (self.max_hops - self.min_hops + 1));
let hop_count = hop_count.min(eligible.len());
// Score nodes: prefer high trust, low latency, diverse countries
let mut scored: Vec<(&LabyrinthNode, f64)> = eligible.iter().map(|n| {
let mut scored: Vec<(&LabyrinthNode, f64)> = eligible.iter().enumerate().map(|(i, n)| {
let rand_component = rand_scores.get(i).copied().unwrap_or(0.0);
let score = n.trust_score * 50.0
+ (1000.0 / (n.latency_ms as f64 + 1.0))
+ n.bandwidth_mbps as f64 * 0.1
+ (self.next_random() % 100) as f64 * 0.3; // randomness
+ rand_component;
(*n, score)
}).collect();