pub struct Hop { /* private fields */ }Expand description
One relay’s identity in a broadcast’s hop chain: a 62-bit varint on the wire.
Names a hop, not an origin::Producer: a relay’s routing table is the
origin, and this is the id it stamps into a route’s hop chain as an announcement
passes through, so a receiver can spot its own id and reject a loop.
Local hops are built with Hop::new or Hop::random, both of which guarantee a
non-zero id so loop detection can work. Remote peers may still send 0; it is legal
on the wire, names nobody, and marks the chain anonymous for route selection.
Implementations§
Source§impl Hop
impl Hop
Sourcepub const UNKNOWN: Self
pub const UNKNOWN: Self
The reserved id 0: no identity.
It stands in for an endpoint that never declared one, and for Lite03 hop-count placeholders. Any number of endpoints can be 0, so it identifies nothing: it is never a loop, never a publisher two chains have in common, and a chain that holds one anywhere is anonymous for route selection.
Sourcepub fn new(id: u64) -> Result<Self, InvalidHop>
pub fn new(id: u64) -> Result<Self, InvalidHop>
Build a hop from a stable id.
The id must be non-zero and fit in the 62-bit QUIC varint range. Wire
decode accepts remote id 0 (Self::UNKNOWN), but a local hop should
not use it because it cannot be excluded for loop detection.
Sourcepub fn random() -> Self
pub fn random() -> Self
Generate a fresh hop with a random non-zero id. Use this for any relay that does not need a stable identity across restarts.
Older @moq/lite clients decode the exclude hop as a JavaScript number
and reject values above 2^53-1. Keep generated IDs in that range while
Self::new accepts the full 62-bit wire range for explicit IDs.
Trait Implementations§
impl Copy for Hop
impl Eq for Hop
Source§impl From<Hop> for Config
impl From<Hop> for Config
Source§fn from(hop: Hop) -> Self
fn from(hop: Hop) -> Self
Config for the given origin id with the defaults of Config::new.