Skip to main content

WaitingQueue

Struct WaitingQueue 

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

Decides which unaccepted peers are recorded as waiting, without storing anything: the policy of TrustStore::record_waiting, for a host that keeps its waiting entries elsewhere.

A source is an IPv4 address (an IPv4-mapped IPv6 address counts as its IPv4 address), an IPv6 prefix of ipv6_prefix bits (/64 unless set, since one holder controls every address of a /64), or no address at all, which is one source. The queue remembers what it admitted, per source, oldest first; it forgets nothing on its own, beyond the per_source entries it keeps for each source.

Implementations§

Source§

impl WaitingQueue
where WaitingSettings: Describe + Inspect,

Source

pub fn non_defaults(&self) -> Vec<NonDefault>

Every setting that differs from its default.

Source§

impl WaitingQueue

Source

pub fn builder() -> WaitingQueueBuilder

A builder with nothing set.

Source§

impl WaitingQueue

Source

pub fn new(limits: WaitingLimits) -> Self

An empty queue under limits with every other setting at its default: WaitingQueue::builder().limits(limits).build().

Source

pub fn settings(&self) -> WaitingSettings

The settings it was built from.

Source

pub fn when_full(&self) -> WhenFull

What it does with a newcomer to a full source.

Source

pub fn record_interval(&self) -> Duration

The least time between two new records from one source.

Source

pub fn limits(&self) -> WaitingLimits

The limits it applies.

Source

pub fn ipv6_prefix(&self) -> u8

The IPv6 prefix length sources are grouped by.

Source

pub fn admit( &mut self, id: PeerId, source: Option<SocketAddr>, stored: usize, now: Instant, ) -> Admission

Decides whether id, from source, is recorded now.

stored is how many waiting entries the host holds; at total or above, nothing is recorded (the newcomer waits, no entry is dropped for it). The same peer from the same source is recorded again only after rerecord. A source records a new peer at most once per record_interval. A source at per_source does what WhenFull says: by default the newcomer is not recorded; with WhenFull::ReplaceOldest its oldest entries are listed in Admission::evict for the host to remove. The host checks itself whether id is already stored, and does not call this then.

Source

pub fn remember( &mut self, id: PeerId, source: Option<SocketAddr>, at: Instant, ) -> Vec<PeerId>

Remembers that id from source was recorded at at, for a host that seeds the queue from entries it stored earlier. Entries past per_source for that source are forgotten, oldest first, and returned.

Source

pub fn prune(&mut self, now: Instant, stored: impl Fn(&PeerId) -> bool)

Forgets every entry the host no longer stores (stored is false for it) once its rerecord time has passed; within it the entry still keeps the same peer from being recorded again from its source.

For a host whose entries another process may accept or remove: without it, the queue remembers them, and its memory grows with every source it has seen.

Source

pub fn len(&self) -> usize

The number of entries remembered, across every source.

Source

pub fn is_empty(&self) -> bool

Whether nothing is remembered.

Source

pub fn forget(&mut self, id: &PeerId)

Forgets id from every source, as when the host accepts or removes it.

Trait Implementations§

Source§

impl Check<WaitingQueue> for Profile
where WaitingSettings: Describe + Inspect,

Source§

fn check(&self, subject: &WaitingQueue, report: &mut Report)

Judges subject, pushing a Finding per expectation.
Source§

impl Clone for WaitingQueue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Configured for WaitingQueue
where WaitingSettings: Describe + Inspect,

Source§

type Settings = WaitingSettings

The type of the settings.
Source§

fn configured(&self) -> &dyn Inspect

The settings, read through [Inspect].
§

fn non_defaults(&self) -> Vec<NonDefault>

Every setting that differs from its default.
Source§

impl Debug for WaitingQueue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<WaitingQueueParts> for WaitingQueue

Source§

fn from(parts: WaitingQueueParts) -> Self

Converts to this type from the input type.

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.