pub struct P2PNode { /* private fields */ }Expand description
Main P2P node structure
Implementations§
Source§impl P2PNode
impl P2PNode
Sourcepub fn new_for_tests() -> Self
pub fn new_for_tests() -> Self
Minimal constructor for tests that avoids real networking
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<SocketAddr>
pub async fn listen_addrs(&self) -> Vec<SocketAddr>
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
Auto Trait Implementations§
impl !Freeze for P2PNode
impl !RefUnwindSafe for P2PNode
impl Send for P2PNode
impl Sync for P2PNode
impl Unpin for P2PNode
impl !UnwindSafe for P2PNode
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.