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 WaitingQueuewhere
WaitingSettings: Describe + Inspect,
impl WaitingQueuewhere
WaitingSettings: Describe + Inspect,
Sourcepub fn non_defaults(&self) -> Vec<NonDefault>
pub fn non_defaults(&self) -> Vec<NonDefault>
Every setting that differs from its default.
Source§impl WaitingQueue
impl WaitingQueue
Sourcepub fn builder() -> WaitingQueueBuilder
pub fn builder() -> WaitingQueueBuilder
A builder with nothing set.
Source§impl WaitingQueue
impl WaitingQueue
Sourcepub fn new(limits: WaitingLimits) -> Self
pub fn new(limits: WaitingLimits) -> Self
An empty queue under limits with every other setting at its default:
WaitingQueue::builder().limits(limits).build().
Sourcepub fn settings(&self) -> WaitingSettings
pub fn settings(&self) -> WaitingSettings
The settings it was built from.
Sourcepub fn record_interval(&self) -> Duration
pub fn record_interval(&self) -> Duration
The least time between two new records from one source.
Sourcepub fn limits(&self) -> WaitingLimits
pub fn limits(&self) -> WaitingLimits
The limits it applies.
Sourcepub fn ipv6_prefix(&self) -> u8
pub fn ipv6_prefix(&self) -> u8
The IPv6 prefix length sources are grouped by.
Sourcepub fn admit(
&mut self,
id: PeerId,
source: Option<SocketAddr>,
stored: usize,
now: Instant,
) -> Admission
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.
Sourcepub fn remember(
&mut self,
id: PeerId,
source: Option<SocketAddr>,
at: Instant,
) -> Vec<PeerId>
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.
Sourcepub fn prune(&mut self, now: Instant, stored: impl Fn(&PeerId) -> bool)
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.
Trait Implementations§
Source§impl Check<WaitingQueue> for Profilewhere
WaitingSettings: Describe + Inspect,
impl Check<WaitingQueue> for Profilewhere
WaitingSettings: Describe + Inspect,
Source§fn check(&self, subject: &WaitingQueue, report: &mut Report)
fn check(&self, subject: &WaitingQueue, report: &mut Report)
subject, pushing a Finding per expectation.Source§impl Clone for WaitingQueue
impl Clone for WaitingQueue
Source§impl Configured for WaitingQueuewhere
WaitingSettings: Describe + Inspect,
impl Configured for WaitingQueuewhere
WaitingSettings: Describe + Inspect,
Source§type Settings = WaitingSettings
type Settings = WaitingSettings
Source§fn configured(&self) -> &dyn Inspect
fn configured(&self) -> &dyn Inspect
Inspect].