pub struct PeerAddress {
pub transport: String,
pub addr: String,
pub priority: u8,
pub seen_at_ms: Option<u64>,
}Expand description
A transport-specific address for reaching a peer.
Each peer can have multiple addresses across different transports, allowing fallback if one transport is unavailable.
Fields§
§transport: StringTransport type (e.g., “udp”, “tor”, “ethernet”).
addr: StringTransport-specific address string.
Format depends on transport type:
- UDP/TCP: “host:port” — IP address or DNS hostname (e.g., “192.168.1.1:2121” or “peer1.example.com:2121”)
- Ethernet: “interface/mac” (e.g., “eth0/aa:bb:cc:dd:ee:ff”)
priority: u8Priority for address selection (lower = preferred). When multiple addresses are available, lower priority addresses are tried first.
seen_at_ms: Option<u64>Wall-clock observation timestamp (Unix ms) for ranking by recency.
None means “no freshness signal” — typically an operator-edited
static config. The dialer sorts candidates by this field descending
(most recent first) and tries every address in one pass; None
values sort last. Skipped from serde so that round-tripping a
config file doesn’t produce noisy empty fields.
Excluded from PartialEq: refreshing the timestamp on a peer that’s
otherwise unchanged should not flag it as “updated” in
crate::endpoint::FipsEndpoint::update_peers’s diff.
Implementations§
Source§impl PeerAddress
impl PeerAddress
Sourcepub fn new(transport: impl Into<String>, addr: impl Into<String>) -> Self
pub fn new(transport: impl Into<String>, addr: impl Into<String>) -> Self
Create a new peer address.
Sourcepub fn with_priority(
transport: impl Into<String>,
addr: impl Into<String>,
priority: u8,
) -> Self
pub fn with_priority( transport: impl Into<String>, addr: impl Into<String>, priority: u8, ) -> Self
Create a new peer address with priority.
Sourcepub fn with_seen_at_ms(self, seen_at_ms: u64) -> Self
pub fn with_seen_at_ms(self, seen_at_ms: u64) -> Self
Tag this address with a freshness timestamp. Used by the dialer to
rank candidates from multiple sources (overlay advert, recent-peers
cache, operator hints) by recency without caring where they came
from. See crate::config::PeerAddress::seen_at_ms.
Trait Implementations§
Source§impl Clone for PeerAddress
impl Clone for PeerAddress
Source§fn clone(&self) -> PeerAddress
fn clone(&self) -> PeerAddress
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PeerAddress
impl Debug for PeerAddress
Source§impl<'de> Deserialize<'de> for PeerAddress
impl<'de> Deserialize<'de> for PeerAddress
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PeerAddress
impl PartialEq for PeerAddress
Source§impl Serialize for PeerAddress
impl Serialize for PeerAddress
impl Eq for PeerAddress
Auto Trait Implementations§
impl Freeze for PeerAddress
impl RefUnwindSafe for PeerAddress
impl Send for PeerAddress
impl Sync for PeerAddress
impl Unpin for PeerAddress
impl UnsafeUnpin for PeerAddress
impl UnwindSafe for PeerAddress
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more