pub struct WebRTCState {
pub peers: RwLock<HashMap<String, PeerEntry>>,
pub connected_count: AtomicUsize,
pub bytes_sent: AtomicU64,
pub bytes_received: AtomicU64,
pub mesh_received: AtomicU64,
pub mesh_forwarded: AtomicU64,
pub mesh_dropped_duplicate: AtomicU64,
/* private fields */
}Expand description
Shared state for the native mesh router.
Fields§
§peers: RwLock<HashMap<String, PeerEntry>>§connected_count: AtomicUsize§bytes_sent: AtomicU64Total bytes sent across all peers (cumulative)
bytes_received: AtomicU64Total bytes received across all peers (cumulative)
mesh_received: AtomicU64Relayless mesh frames received and accepted.
mesh_forwarded: AtomicU64Relayless mesh frames forwarded to peers.
mesh_dropped_duplicate: AtomicU64Relayless mesh frames/events dropped due to dedupe.
Implementations§
Source§impl WebRTCState
impl WebRTCState
pub fn new() -> Self
pub fn new_with_routing( selection_strategy: SelectionStrategy, fairness_enabled: bool, request_dispatch: RequestDispatchConfig, ) -> Self
pub fn new_with_routing_and_cashu( selection_strategy: SelectionStrategy, fairness_enabled: bool, request_dispatch: RequestDispatchConfig, request_timeout: Duration, cashu_routing: CashuRoutingConfig, payment_client: Option<Arc<dyn CashuPaymentClient>>, mint_metadata: Option<Arc<CashuMintMetadataStore>>, ) -> Self
pub async fn set_local_buses(&self, buses: Vec<SharedLocalNostrBus>)
pub async fn add_local_bus(&self, bus: SharedLocalNostrBus)
pub async fn set_multicast_bus(&self, bus: Option<Arc<MulticastNostrBus>>)
Sourcepub async fn reset_runtime_state(&self)
pub async fn reset_runtime_state(&self)
Drop all live peer sessions and clear topology-specific state while keeping cumulative bandwidth counters intact.
Sourcepub fn get_bandwidth(&self) -> (u64, u64)
pub fn get_bandwidth(&self) -> (u64, u64)
Get current bandwidth stats (bytes sent/received)
pub fn get_mesh_stats(&self) -> (u64, u64, u64)
pub fn record_mesh_received(&self)
pub fn record_mesh_forwarded(&self, count: u64)
pub fn record_mesh_duplicate_drop(&self)
Sourcepub async fn record_sent(&self, peer_id: &str, bytes: u64)
pub async fn record_sent(&self, peer_id: &str, bytes: u64)
Record bytes sent (global + per-peer)
Sourcepub async fn record_received(&self, peer_id: &str, bytes: u64)
pub async fn record_received(&self, peer_id: &str, bytes: u64)
Record bytes received (global + per-peer)
Sourcepub async fn request_from_peers(&self, hash_hex: &str) -> Option<Vec<u8>>
pub async fn request_from_peers(&self, hash_hex: &str) -> Option<Vec<u8>>
Request content by hash from connected peers Queries peers in adaptive selector order with hedged fanout waves. Returns the first successful response, or None if no peer has it
Sourcepub async fn request_from_peers_with_source(
&self,
hash_hex: &str,
) -> Option<(Vec<u8>, String)>
pub async fn request_from_peers_with_source( &self, hash_hex: &str, ) -> Option<(Vec<u8>, String)>
Request content by hash from connected peers, returning data and source peer.
Sourcepub async fn resolve_root_from_peers(
&self,
owner_pubkey: &str,
tree_name: &str,
per_peer_timeout: Duration,
) -> Option<PeerRootEvent>
pub async fn resolve_root_from_peers( &self, owner_pubkey: &str, tree_name: &str, per_peer_timeout: Duration, ) -> Option<PeerRootEvent>
Resolve a hashtree root event through connected peers using Nostr REQ/EOSE over WebRTC.
pub async fn resolve_root_from_local_buses_with_source( &self, owner_pubkey: &str, tree_name: &str, timeout: Duration, ) -> Option<(&'static str, PeerRootEvent)>
pub async fn resolve_root_from_local_buses( &self, owner_pubkey: &str, tree_name: &str, timeout: Duration, ) -> Option<PeerRootEvent>
pub async fn resolve_root_from_multicast( &self, owner_pubkey: &str, tree_name: &str, timeout: Duration, ) -> Option<PeerRootEvent>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WebRTCState
impl !RefUnwindSafe for WebRTCState
impl Send for WebRTCState
impl Sync for WebRTCState
impl Unpin for WebRTCState
impl UnsafeUnpin for WebRTCState
impl !UnwindSafe for WebRTCState
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> 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<'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