pub struct P2PNode { /* private fields */ }Expand description
Main P2P node structure
Implementations§
Source§impl P2PNode
impl P2PNode
Sourcepub async fn new(config: NodeConfig) -> Result<Self>
pub async fn new(config: NodeConfig) -> Result<Self>
Create a new P2P node with the given configuration
Sourcepub fn builder() -> NodeBuilder
pub fn builder() -> NodeBuilder
Create a new node builder
Sourcepub async fn initialize_mcp_network(&self) -> Result<()>
pub async fn initialize_mcp_network(&self) -> Result<()>
Initialize MCP network integration This method should be called after node creation to enable MCP network features
pub fn local_addr(&self) -> Option<String>
pub async fn subscribe(&self, topic: &str) -> Result<()>
pub async fn publish(&self, topic: &str, data: &[u8]) -> Result<()>
Sourcepub fn config(&self) -> &NodeConfig
pub fn config(&self) -> &NodeConfig
Get the node configuration
Sourcepub async fn is_running(&self) -> bool
pub async fn is_running(&self) -> bool
Check if the node is running
Sourcepub async fn listen_addrs(&self) -> Vec<Multiaddr> ⓘ
pub async fn listen_addrs(&self) -> Vec<Multiaddr> ⓘ
Get the current listen addresses
Sourcepub async fn connected_peers(&self) -> Vec<PeerId> ⓘ
pub async fn connected_peers(&self) -> Vec<PeerId> ⓘ
Get connected peers
Sourcepub async fn peer_count(&self) -> usize
pub async fn peer_count(&self) -> usize
Get peer count
Sourcepub async fn connect_peer(&self, address: &str) -> Result<PeerId>
pub async fn connect_peer(&self, address: &str) -> Result<PeerId>
Connect to a peer
Sourcepub async fn disconnect_peer(&self, peer_id: &PeerId) -> Result<()>
pub async fn disconnect_peer(&self, peer_id: &PeerId) -> Result<()>
Disconnect from a peer
Source§impl P2PNode
impl P2PNode
Sourcepub fn subscribe_events(&self) -> Receiver<P2PEvent>
pub fn subscribe_events(&self) -> Receiver<P2PEvent>
Subscribe to network events
Sourcepub fn mcp_server(&self) -> Option<&Arc<MCPServer>>
pub fn mcp_server(&self) -> Option<&Arc<MCPServer>>
Get MCP server reference
Sourcepub async fn register_mcp_tool(&self, tool: Tool) -> Result<()>
pub async fn register_mcp_tool(&self, tool: Tool) -> Result<()>
Register a tool in the MCP server
Sourcepub async fn call_mcp_tool(
&self,
tool_name: &str,
arguments: Value,
) -> Result<Value>
pub async fn call_mcp_tool( &self, tool_name: &str, arguments: Value, ) -> Result<Value>
Call a local MCP tool
Sourcepub async fn call_remote_mcp_tool(
&self,
peer_id: &PeerId,
tool_name: &str,
arguments: Value,
) -> Result<Value>
pub async fn call_remote_mcp_tool( &self, peer_id: &PeerId, tool_name: &str, arguments: Value, ) -> Result<Value>
Call a remote MCP tool on another node
Sourcepub async fn list_mcp_tools(&self) -> Result<Vec<String>>
pub async fn list_mcp_tools(&self) -> Result<Vec<String>>
List available tools in the local MCP server
Sourcepub async fn discover_remote_mcp_services(&self) -> Result<Vec<MCPService>>
pub async fn discover_remote_mcp_services(&self) -> Result<Vec<MCPService>>
Discover remote MCP services in the network
Sourcepub async fn list_remote_mcp_tools(
&self,
peer_id: &PeerId,
) -> Result<Vec<String>>
pub async fn list_remote_mcp_tools( &self, peer_id: &PeerId, ) -> Result<Vec<String>>
List tools available on a specific remote peer
Sourcepub async fn mcp_stats(&self) -> Result<MCPServerStats>
pub async fn mcp_stats(&self) -> Result<MCPServerStats>
Get MCP server statistics
Sourcepub async fn resource_metrics(&self) -> Result<ResourceMetrics>
pub async fn resource_metrics(&self) -> Result<ResourceMetrics>
Get production resource metrics
Sourcepub async fn health_check(&self) -> Result<()>
pub async fn health_check(&self) -> Result<()>
Check system health
Sourcepub fn production_config(&self) -> Option<&ProductionConfig>
pub fn production_config(&self) -> Option<&ProductionConfig>
Get production configuration (if enabled)
Sourcepub fn is_production_mode(&self) -> bool
pub fn is_production_mode(&self) -> bool
Check if production hardening is enabled
Sourcepub async fn add_discovered_peer(
&self,
peer_id: PeerId,
addresses: Vec<String>,
) -> Result<()>
pub async fn add_discovered_peer( &self, peer_id: PeerId, addresses: Vec<String>, ) -> Result<()>
Add a discovered peer to the bootstrap cache
Sourcepub async fn update_peer_metrics(
&self,
peer_id: &PeerId,
success: bool,
latency_ms: Option<u64>,
_error: Option<String>,
) -> Result<()>
pub async fn update_peer_metrics( &self, peer_id: &PeerId, success: bool, latency_ms: Option<u64>, _error: Option<String>, ) -> Result<()>
Update connection metrics for a peer in the bootstrap cache
Sourcepub async fn get_bootstrap_cache_stats(&self) -> Result<Option<CacheStats>>
pub async fn get_bootstrap_cache_stats(&self) -> Result<Option<CacheStats>>
Get bootstrap cache statistics
Sourcepub async fn cached_peer_count(&self) -> usize
pub async fn cached_peer_count(&self) -> usize
Get the number of cached bootstrap peers
Sourcepub async fn discover_mcp_services(&self) -> Result<Vec<MCPService>>
pub async fn discover_mcp_services(&self) -> Result<Vec<MCPService>>
Discover available MCP services on the network
Sourcepub async fn get_all_mcp_services(&self) -> Result<Vec<MCPService>>
pub async fn get_all_mcp_services(&self) -> Result<Vec<MCPService>>
Get all known MCP services (local + remote)
Sourcepub async fn find_mcp_services_with_tool(
&self,
tool_name: &str,
) -> Result<Vec<MCPService>>
pub async fn find_mcp_services_with_tool( &self, tool_name: &str, ) -> Result<Vec<MCPService>>
Find MCP services that provide a specific tool
Sourcepub async fn announce_mcp_services(&self) -> Result<()>
pub async fn announce_mcp_services(&self) -> Result<()>
Manually announce local MCP services
Sourcepub async fn refresh_mcp_service_discovery(&self) -> Result<()>
pub async fn refresh_mcp_service_discovery(&self) -> Result<()>
Refresh MCP service discovery
Sourcepub async fn query_peer_mcp_services(&self, peer_id: &PeerId) -> Result<()>
pub async fn query_peer_mcp_services(&self, peer_id: &PeerId) -> Result<()>
Send a service discovery query to a specific peer
Sourcepub async fn broadcast_mcp_service_discovery(&self) -> Result<()>
pub async fn broadcast_mcp_service_discovery(&self) -> Result<()>
Broadcast service discovery query to all connected peers