pub struct LocalGraph { /* private fields */ }Expand description
Local view of the swarm: known nodes, edges, and a dedup
cache for incoming pingwaves. Holds the proximity-routing
state — see BehaviorContext::propagate for the consumer
side and mesh.rs pingwave dispatch for the producer side.
Implementations§
Source§impl LocalGraph
impl LocalGraph
Sourcepub fn with_node_timeout(self, timeout: Duration) -> Self
pub fn with_node_timeout(self, timeout: Duration) -> Self
Set node timeout
Sourcepub fn create_pingwave(&self) -> Pingwave
pub fn create_pingwave(&self) -> Pingwave
Create a new pingwave to broadcast
Sourcepub fn on_pingwave(&self, pw: Pingwave, from: SocketAddr) -> Option<Pingwave>
pub fn on_pingwave(&self, pw: Pingwave, from: SocketAddr) -> Option<Pingwave>
Process an incoming pingwave.
Returns Some(pingwave) if it should be forwarded, None otherwise.
seen_pingwaves and nodes are soft-capped via
MAX_SEEN_PINGWAVES / MAX_GRAPH_NODES: existing
entries continue to update, but novel keys are dropped
once the cap is reached. The next periodic
evict_stale_* sweep reclaims slots for legitimate
nodes/pingwaves so admission resumes once memory pressure
eases. Without the caps, a peer flooding pingwaves with
random (origin_id, seq) could grow both maps at
line-rate between the periodic eviction sweeps.
Sourcepub fn on_capability(&self, ad: CapabilityAd, from: SocketAddr)
pub fn on_capability(&self, ad: CapabilityAd, from: SocketAddr)
Process a capability advertisement
Sourcepub fn nodes_within_hops(&self, max_hops: u8) -> Vec<NodeInfo>
pub fn nodes_within_hops(&self, max_hops: u8) -> Vec<NodeInfo>
Get nodes within a specific hop distance
Sourcepub fn find_by_tool(&self, tool: &str) -> Vec<NodeInfo>
pub fn find_by_tool(&self, tool: &str) -> Vec<NodeInfo>
Find nodes with a specific capability (tool)
Sourcepub fn find_by_tag(&self, tag: &str) -> Vec<NodeInfo>
pub fn find_by_tag(&self, tag: &str) -> Vec<NodeInfo>
Find nodes with a specific tag
Sourcepub fn find_with_gpu(&self) -> Vec<NodeInfo>
pub fn find_with_gpu(&self) -> Vec<NodeInfo>
Find nodes with GPU
Sourcepub fn path_to(&self, dest: u64) -> Option<Vec<u64>>
pub fn path_to(&self, dest: u64) -> Option<Vec<u64>>
Get shortest path to a node (BFS).
Reconstructs the path from a parent map at the end rather than cloning the full path per neighbor — avoids quadratic behavior on long paths or wide frontiers.
Sourcepub fn stats(&self) -> GraphStats
pub fn stats(&self) -> GraphStats
Get graph statistics
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get node count
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get edge count