Skip to main content

FireCloudNode

Struct FireCloudNode 

Source
pub struct FireCloudNode { /* private fields */ }
Expand description

A FireCloud P2P node

Implementations§

Source§

impl FireCloudNode

Source

pub async fn new(config: NodeConfig) -> NetResult<Self>

Create a new FireCloud node

Source

pub fn peer_latency(&self, peer: &PeerId) -> Option<Duration>

Get the latest measured RTT for a peer, if available

Source

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

Source

pub fn is_local_peer(&self, peer: &PeerId) -> bool

Check if a peer was discovered via mDNS (i.e., is on the local network)

Source

pub fn local_peers(&self) -> &HashSet<PeerId>

Get list of local (mDNS-discovered) peers

Source

pub fn choose_best_peer(&self, candidates: &[PeerId]) -> Option<PeerId>

Choose the best peer from candidates for chunk retrieval. Priority:

  1. Local peers (mDNS-discovered) with lowest latency
  2. Any peer with lowest latency
  3. First candidate if no latency info available
Source

pub fn local_peer_id(&self) -> PeerId

Get local peer ID

Source

pub fn known_peers(&self) -> &HashSet<PeerId>

Get known peers

Source

pub fn connected_peers_count(&self) -> usize

Get the number of connected peers

Source

pub fn connected_peers(&self) -> Vec<PeerId>

Get all connected peer IDs

Source

pub fn kademlia_peers_count(&self) -> usize

Get Kademlia routing table size (approximate)

Source

pub fn add_bootstrap_peer(&mut self, peer_id: &PeerId, addr: Multiaddr)

Add a bootstrap peer to Kademlia

Source

pub fn bootstrap(&mut self) -> NetResult<QueryId>

Trigger Kademlia bootstrap process

Source

pub fn subscribe(&mut self, topic: &str) -> NetResult<()>

Subscribe to a GossipSub topic

Source

pub fn publish(&mut self, topic: &str, data: Vec<u8>) -> NetResult<()>

Publish a message to a topic

Source

pub fn dial(&mut self, addr: Multiaddr) -> NetResult<()>

Dial a peer by address

Source

pub fn health_monitor(&self) -> &HealthMonitor

Get reference to health monitor

Source

pub fn get_best_peer_for_transfer(&self) -> Option<PeerId>

Get best peer for transfer (uses health monitor)

Source

pub fn get_healthy_peers(&self) -> Vec<PeerId>

Get healthy peers sorted by health score

Source

pub fn cleanup_offline_peers(&mut self)

Cleanup offline peers from health monitor

Source

pub fn send_transfer_request( &mut self, peer: &PeerId, request: TransferRequest, ) -> OutboundRequestId

Send a transfer request to a peer

Source

pub fn respond_transfer( &mut self, channel: ResponseChannel<TransferResponse>, response: TransferResponse, ) -> NetResult<()>

Send a response to a transfer request

Source

pub fn request_chunk( &mut self, peer: &PeerId, hash: String, ) -> OutboundRequestId

Request a chunk from a peer

Source

pub fn send_message_request( &mut self, peer: &PeerId, request: MessageRequest, ) -> OutboundRequestId

Send a message request to a peer

Source

pub fn respond_message( &mut self, channel: ResponseChannel<MessageResponse>, response: MessageResponse, ) -> NetResult<()>

Send a response to a message request

Source

pub fn send_friend_request( &mut self, peer: &PeerId, name: Option<String>, ) -> OutboundRequestId

Send a friend request to a peer

Source

pub fn send_friend_accept(&mut self, peer: &PeerId) -> OutboundRequestId

Accept a friend request from a peer

Source

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!)

Source

pub fn ping_peer(&mut self, peer: &PeerId) -> OutboundRequestId

Ping a peer to check if they’re online

Source

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

Source

pub fn check_chunk(&mut self, peer: &PeerId, hash: String) -> OutboundRequestId

Check if a peer has a chunk

Source

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

Source

pub fn stop_announcing_file(&mut self, file_id: &str)

Stop announcing as a provider for a file

Source

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

Source

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

Source

pub fn get_dht_record(&mut self, key: &str) -> QueryId

Get a record from the DHT Results will come via NodeEvent::RecordFound

Source

pub fn bootstrap_dht(&mut self) -> Result<QueryId, NoKnownPeers>

Bootstrap Kademlia DHT (find closest peers to self)

Source

pub async fn run(&mut self)

Run the node event loop

Source

pub async fn poll_event(&mut self) -> Option<NodeEvent>

Poll for the next event (non-blocking version for integration)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more