pub struct InterfaceAnnounceQueue {
pub entries: Vec<AnnounceQueueEntry>,
pub announce_allowed_at: f64,
}Expand description
Per-interface announce queue with bandwidth tracking.
Fields§
§entries: Vec<AnnounceQueueEntry>Queued announce entries.
announce_allowed_at: f64Earliest time another announce is allowed on this interface.
Implementations§
Source§impl InterfaceAnnounceQueue
impl InterfaceAnnounceQueue
pub fn new() -> Self
Sourcepub fn insert(&mut self, entry: AnnounceQueueEntry)
pub fn insert(&mut self, entry: AnnounceQueueEntry)
Insert an announce into the queue. If an entry for the same destination already exists, update it if the new one has fewer hops or is newer.
Sourcepub fn remove_stale(&mut self, now: f64)
pub fn remove_stale(&mut self, now: f64)
Remove stale entries (older than QUEUED_ANNOUNCE_LIFE).
Sourcepub fn select_next(&self) -> Option<usize>
pub fn select_next(&self) -> Option<usize>
Select the next announce to send: minimum hops, then oldest (FIFO). Returns the index of the selected entry, or None if empty.
Sourcepub fn is_allowed(&self, now: f64) -> bool
pub fn is_allowed(&self, now: f64) -> bool
Check if an announce is allowed now based on bandwidth.
Sourcepub fn calculate_next_allowed(
now: f64,
raw_len: usize,
bitrate: u64,
announce_cap: f64,
) -> f64
pub fn calculate_next_allowed( now: f64, raw_len: usize, bitrate: u64, announce_cap: f64, ) -> f64
Calculate the next allowed time after sending an announce.
raw_len: size of the announce in bytes
bitrate: interface bitrate in bits/second
announce_cap: fraction of bitrate reserved for announces
Trait Implementations§
Source§impl Clone for InterfaceAnnounceQueue
impl Clone for InterfaceAnnounceQueue
Source§fn clone(&self) -> InterfaceAnnounceQueue
fn clone(&self) -> InterfaceAnnounceQueue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for InterfaceAnnounceQueue
impl RefUnwindSafe for InterfaceAnnounceQueue
impl Send for InterfaceAnnounceQueue
impl Sync for InterfaceAnnounceQueue
impl Unpin for InterfaceAnnounceQueue
impl UnwindSafe for InterfaceAnnounceQueue
Blanket Implementations§
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
Mutably borrows from an owned value. Read more