pub struct FireCloudNode { /* private fields */ }Expand description
A FireCloud P2P node
Implementations§
Source§impl FireCloudNode
impl FireCloudNode
Sourcepub async fn new(config: NodeConfig) -> NetResult<Self>
pub async fn new(config: NodeConfig) -> NetResult<Self>
Create a new FireCloud node
Sourcepub fn peer_latency(&self, peer: &PeerId) -> Option<Duration>
pub fn peer_latency(&self, peer: &PeerId) -> Option<Duration>
Get the latest measured RTT for a peer, if available
Sourcepub fn select_lowest_latency_peer(
&self,
candidates: &[PeerId],
) -> Option<PeerId>
pub fn select_lowest_latency_peer( &self, candidates: &[PeerId], ) -> Option<PeerId>
Select the peer with the lowest recorded latency from the provided list Returns None if no latencies are known for the provided peers
Sourcepub fn is_local_peer(&self, peer: &PeerId) -> bool
pub fn is_local_peer(&self, peer: &PeerId) -> bool
Check if a peer was discovered via mDNS (i.e., is on the local network)
Sourcepub fn local_peers(&self) -> &HashSet<PeerId>
pub fn local_peers(&self) -> &HashSet<PeerId>
Get list of local (mDNS-discovered) peers
Sourcepub fn choose_best_peer(&self, candidates: &[PeerId]) -> Option<PeerId>
pub fn choose_best_peer(&self, candidates: &[PeerId]) -> Option<PeerId>
Choose the best peer from candidates for chunk retrieval. Priority:
- Local peers (mDNS-discovered) with lowest latency
- Any peer with lowest latency
- First candidate if no latency info available
Sourcepub fn local_peer_id(&self) -> PeerId
pub fn local_peer_id(&self) -> PeerId
Get local peer ID
Sourcepub fn known_peers(&self) -> &HashSet<PeerId>
pub fn known_peers(&self) -> &HashSet<PeerId>
Get known peers
Sourcepub fn connected_peers_count(&self) -> usize
pub fn connected_peers_count(&self) -> usize
Get the number of connected peers
Sourcepub fn connected_peers(&self) -> Vec<PeerId>
pub fn connected_peers(&self) -> Vec<PeerId>
Get all connected peer IDs
Sourcepub fn kademlia_peers_count(&self) -> usize
pub fn kademlia_peers_count(&self) -> usize
Get Kademlia routing table size (approximate)
Sourcepub fn add_bootstrap_peer(&mut self, peer_id: &PeerId, addr: Multiaddr)
pub fn add_bootstrap_peer(&mut self, peer_id: &PeerId, addr: Multiaddr)
Add a bootstrap peer to Kademlia
Sourcepub fn publish(&mut self, topic: &str, data: Vec<u8>) -> NetResult<()>
pub fn publish(&mut self, topic: &str, data: Vec<u8>) -> NetResult<()>
Publish a message to a topic
Sourcepub fn health_monitor(&self) -> &HealthMonitor
pub fn health_monitor(&self) -> &HealthMonitor
Get reference to health monitor
Sourcepub fn get_best_peer_for_transfer(&self) -> Option<PeerId>
pub fn get_best_peer_for_transfer(&self) -> Option<PeerId>
Get best peer for transfer (uses health monitor)
Sourcepub fn get_healthy_peers(&self) -> Vec<PeerId>
pub fn get_healthy_peers(&self) -> Vec<PeerId>
Get healthy peers sorted by health score
Sourcepub fn cleanup_offline_peers(&mut self)
pub fn cleanup_offline_peers(&mut self)
Cleanup offline peers from health monitor
Sourcepub fn send_transfer_request(
&mut self,
peer: &PeerId,
request: TransferRequest,
) -> OutboundRequestId
pub fn send_transfer_request( &mut self, peer: &PeerId, request: TransferRequest, ) -> OutboundRequestId
Send a transfer request to a peer
Sourcepub fn respond_transfer(
&mut self,
channel: ResponseChannel<TransferResponse>,
response: TransferResponse,
) -> NetResult<()>
pub fn respond_transfer( &mut self, channel: ResponseChannel<TransferResponse>, response: TransferResponse, ) -> NetResult<()>
Send a response to a transfer request
Sourcepub fn request_chunk(
&mut self,
peer: &PeerId,
hash: String,
) -> OutboundRequestId
pub fn request_chunk( &mut self, peer: &PeerId, hash: String, ) -> OutboundRequestId
Request a chunk from a peer
Sourcepub fn send_message_request(
&mut self,
peer: &PeerId,
request: MessageRequest,
) -> OutboundRequestId
pub fn send_message_request( &mut self, peer: &PeerId, request: MessageRequest, ) -> OutboundRequestId
Send a message request to a peer
Sourcepub fn respond_message(
&mut self,
channel: ResponseChannel<MessageResponse>,
response: MessageResponse,
) -> NetResult<()>
pub fn respond_message( &mut self, channel: ResponseChannel<MessageResponse>, response: MessageResponse, ) -> NetResult<()>
Send a response to a message request
Sourcepub fn send_friend_request(
&mut self,
peer: &PeerId,
name: Option<String>,
) -> OutboundRequestId
pub fn send_friend_request( &mut self, peer: &PeerId, name: Option<String>, ) -> OutboundRequestId
Send a friend request to a peer
Sourcepub fn send_friend_accept(&mut self, peer: &PeerId) -> OutboundRequestId
pub fn send_friend_accept(&mut self, peer: &PeerId) -> OutboundRequestId
Accept a friend request from a peer
Sourcepub fn send_direct_message(
&mut self,
peer: &PeerId,
content: Vec<u8>,
message_id: String,
timestamp: i64,
) -> OutboundRequestId
pub fn send_direct_message( &mut self, peer: &PeerId, content: Vec<u8>, message_id: String, timestamp: i64, ) -> OutboundRequestId
Send a direct message to a friend (content already padded to 1KB!)
Sourcepub fn ping_peer(&mut self, peer: &PeerId) -> OutboundRequestId
pub fn ping_peer(&mut self, peer: &PeerId) -> OutboundRequestId
Ping a peer to check if they’re online
Sourcepub fn store_chunk_on_peer(
&mut self,
peer: &PeerId,
hash: String,
data: Vec<u8>,
original_size: u64,
) -> OutboundRequestId
pub fn store_chunk_on_peer( &mut self, peer: &PeerId, hash: String, data: Vec<u8>, original_size: u64, ) -> OutboundRequestId
Store a chunk on a peer
Sourcepub fn check_chunk(&mut self, peer: &PeerId, hash: String) -> OutboundRequestId
pub fn check_chunk(&mut self, peer: &PeerId, hash: String) -> OutboundRequestId
Check if a peer has a chunk
Sourcepub fn announce_file(&mut self, file_id: &str) -> QueryId
pub fn announce_file(&mut self, file_id: &str) -> QueryId
Announce this node as a provider for a file (by file_id) Other nodes can then find us via get_providers
Sourcepub fn stop_announcing_file(&mut self, file_id: &str)
pub fn stop_announcing_file(&mut self, file_id: &str)
Stop announcing as a provider for a file
Sourcepub fn find_file_providers(&mut self, file_id: &str) -> QueryId
pub fn find_file_providers(&mut self, file_id: &str) -> QueryId
Find providers for a file (by file_id) Results will come via NodeEvent::ProvidersFound
Sourcepub fn put_dht_record(&mut self, key: &str, value: Vec<u8>) -> QueryId
pub fn put_dht_record(&mut self, key: &str, value: Vec<u8>) -> QueryId
Store a record in the DHT (for manifest metadata) Results will come via NodeEvent::RecordStored
Sourcepub fn get_dht_record(&mut self, key: &str) -> QueryId
pub fn get_dht_record(&mut self, key: &str) -> QueryId
Get a record from the DHT Results will come via NodeEvent::RecordFound
Sourcepub fn bootstrap_dht(&mut self) -> Result<QueryId, NoKnownPeers>
pub fn bootstrap_dht(&mut self) -> Result<QueryId, NoKnownPeers>
Bootstrap Kademlia DHT (find closest peers to self)
Sourcepub async fn poll_event(&mut self) -> Option<NodeEvent>
pub async fn poll_event(&mut self) -> Option<NodeEvent>
Poll for the next event (non-blocking version for integration)
Auto Trait Implementations§
impl !Freeze for FireCloudNode
impl !RefUnwindSafe for FireCloudNode
impl Send for FireCloudNode
impl !Sync for FireCloudNode
impl Unpin for FireCloudNode
impl !UnwindSafe for FireCloudNode
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more