pub struct DHTNode {
pub peer_id: PeerId,
pub addresses: Vec<MultiAddr>,
pub address_types: Vec<AddressType>,
pub distance: Option<Vec<u8>>,
pub reliability: f64,
pub address_authority: Option<AddressAuthority>,
}Expand description
DHT node representation for network operations.
The addresses field stores one or more typed MultiAddr values.
Peers may be multi-homed or reachable via NAT traversal at several
endpoints.
Fields§
§peer_id: PeerId§addresses: Vec<MultiAddr>§address_types: Vec<AddressType>Type tag for each address, parallel to addresses by index.
Defaults to empty on deserialization (legacy records or wire data from
nodes that predate ADR-014). When empty, callers treat all addresses
as AddressType::Unverified — a legacy peer never asserted
reachability for its published sockets, so the conservative default
is “publisher did not claim direct-dialability.” This excludes the
entries from first_direct_dialable (relay-candidate selection)
while keeping them in the general dial priority queue as a
last-resort cold-start fallback.
Populated when constructing from DHT routing-table entries so
consumers (e.g., saorsa-node) can inspect the address types of
peers returned by find_closest_nodes_local().
distance: Option<Vec<u8>>Optional per-record metadata. In current DHT responses this may carry
a marker-encoded PublishAddressSet sequence for wire compatibility.
That value has no authority without locally established owner provenance.
reliability: f64Locally established ownership proof; never trusted through deserialization.
Implementations§
Source§impl DHTNode
impl DHTNode
Sourcepub fn publisher_address_set_unix_ns(&self) -> Option<u64>
pub fn publisher_address_set_unix_ns(&self) -> Option<u64>
Publisher-provided Unix-nanosecond sequence from the latest
PublishAddressSet, when this record carries one.
This value is derived from the publisher’s wall clock. It is useful for diagnostics but is not a trusted timestamp or proof of peer uptime.
Sourcepub fn typed_addresses_by_priority(&self) -> Vec<(MultiAddr, AddressType)>
pub fn typed_addresses_by_priority(&self) -> Vec<(MultiAddr, AddressType)>
Address/type pairs sorted by address-type priority.
The stable sort preserves publisher order within each priority tier.
Sourcepub fn address_and_type_labels_by_priority(
&self,
) -> Vec<(MultiAddr, &'static str)>
pub fn address_and_type_labels_by_priority( &self, ) -> Vec<(MultiAddr, &'static str)>
Address/type-label pairs sorted by address-type priority.
Sourcepub fn address_type_labels_by_priority(&self) -> Vec<&'static str>
pub fn address_type_labels_by_priority(&self) -> Vec<&'static str>
Address type labels parallel to Self::addresses_by_priority.
Sourcepub fn typed_addresses(&self) -> Vec<(MultiAddr, AddressType)>
pub fn typed_addresses(&self) -> Vec<(MultiAddr, AddressType)>
Pair each address with its type tag.
Local-scope IP addresses are always returned as AddressType::Lan,
even if the sender advertised a stronger tag. Other untagged entries
(legacy records that predate ADR-014, or any position past the end of
address_types) default to AddressType::Unverified. A legacy
publisher never asserted reachability for these sockets, so we refuse
to let them stand in for a verified Direct tag.
The returned vec preserves the storage order from addresses;
callers that need Relay-first ordering should pass the result to
DhtNetworkManager::dialable_addresses_typed or use
Self::addresses_by_priority for a pre-sorted Vec<MultiAddr>.
Sourcepub fn addresses_by_priority(&self) -> Vec<MultiAddr>
pub fn addresses_by_priority(&self) -> Vec<MultiAddr>
Addresses sorted by AddressType priority: Relay first, then
Direct, Unverified, and Lan. Within each tier the original insertion
order is preserved (stable sort).
Use this instead of raw addresses whenever the caller needs to
dial or pass addresses to a consumer that will try them in order
(e.g., send_message, reconnect_and_send).
Sourcepub fn merge_from(&mut self, other: DHTNode)
pub fn merge_from(&mut self, other: DHTNode)
Combine lookup views without contaminating an owner-proven replacement.
A signed V2 publication replaces the entire V1 view regardless of its sequence. Once V2 is known, only a newer V2 publication can replace it. Unsigned hints cannot change an owner-proven view. When both views are unsequenced, merge addresses and retain the strongest duplicate tag.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DHTNode
impl<'de> Deserialize<'de> for DHTNode
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DHTNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DHTNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl LookupNode for DHTNode
impl LookupNode for DHTNode
Source§fn lookup_peer_id(&self) -> [u8; 32]
fn lookup_peer_id(&self) -> [u8; 32]
Source§impl Serialize for DHTNode
impl Serialize for DHTNode
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for DHTNode
impl RefUnwindSafe for DHTNode
impl Send for DHTNode
impl Sync for DHTNode
impl Unpin for DHTNode
impl UnsafeUnpin for DHTNode
impl UnwindSafe for DHTNode
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
impl<'de, T> BorrowedRpcObject<'de> for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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