Skip to main content

LinkState

Struct LinkState 

Source
pub struct LinkState {
Show 13 fields pub handshake_sent: bool, pub snapshot_sent: bool, pub told: HashMap<String, u64>, pub last_data_send_ms: Option<u64>, pub send_jitter_ms: u64, pub self_interval_secs: u32, pub last_backoff_applied_ms: Option<u64>, pub phase: RecvPhase, pub remote_declared_secs: Option<u32>, pub last_arrival_ms: Option<u64>, pub strikes: u32, pub muted: bool, pub received: HashMap<String, u64>,
}
Expand description

All PEX state for one link (both directions). Created on link_up / first inbound message and discarded on link_down (SPEC §5.5).

Fields§

§handshake_sent: bool

Whether we have sent our pex_handshake on this link.

§snapshot_sent: bool

Whether we have sent our one pex_snapshot on this link.

§told: HashMap<String, u64>

Per-link told-state (SPEC §9.1): peer_id → advertised-content fingerprint hash (PeerEntry::fingerprint_hash, a Copy, allocation-free u64 rather than the display-oriented String form — #179 MED optimization). Deltas are computed relative to this; an unchanged told entry is never re-advertised.

§last_data_send_ms: Option<u64>

When we last sent a data message (snapshot or delta) on this link, in now_ms. None until the snapshot goes out; the cadence spaces subsequent sends from here (SPEC §6.1).

§send_jitter_ms: u64

The additive jitter (ms) drawn for the current schedule interval (SPEC §6.3).

§self_interval_secs: u32

Our own declared interval (seconds) for this link — starts at the configured value and MAY double on receiving pex_error code 3 (SPEC §6.4), capped at PEX_MAX_INTERVAL.

§last_backoff_applied_ms: Option<u64>

When a pex_error code-3 back-off was last actually applied to self_interval_secs, in now_ms (LOW #179 fix). Bounds how often an unauthenticated pex_error can move our send cadence: a further code-3 is honored at most once per (pre-doubling) effective interval, so a peer spamming code-3 cannot ratchet the interval to PEX_MAX_INTERVAL faster than a single genuine violation could.

§phase: RecvPhase

The inbound state machine (SPEC §5.3).

§remote_declared_secs: Option<u32>

The remote’s handshake-declared interval (seconds), once its handshake arrived. Used as the arrival-floor basis (SPEC §6.4) and as a spacing floor for our own sends (SPEC §6.2).

§last_arrival_ms: Option<u64>

When the last inbound data message arrived, in now_ms — the SPEC §6.4 clock.

§strikes: u32

Violation strikes counted on the incoming direction (SPEC §11.2).

§muted: bool

Whether the incoming direction is muted (all further inbound PEX ignored) — SPEC §5.2, §11.2.

§received: HashMap<String, u64>

peer_ids this link has told us (via snapshot / delta added) — so a later dropped can be attributed to it and ignored for ids it never told us (SPEC §4.4, §8.3).

Implementations§

Source§

impl LinkState

Source

pub fn new(self_interval_secs: u32) -> Self

A fresh link: both directions at their start state, no told/received history.

Trait Implementations§

Source§

impl Clone for LinkState

Source§

fn clone(&self) -> LinkState

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 Debug for LinkState

Source§

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

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

impl Default for LinkState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

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

Source§

fn vzip(self) -> V