pub struct NodeRecord {
pub address: IpAddr,
pub udp_port: u16,
pub tcp_port: u16,
pub id: PeerId,
}
Expand description
Represents a ENR in discovery.
Note: this is only an excerpt of the NodeRecord
data structure.
Fields§
§address: IpAddr
The Address of a node.
udp_port: u16
UDP discovery port.
tcp_port: u16
TCP port of the port that accepts connections.
id: PeerId
Public key of the discovery service
Implementations§
Source§impl NodeRecord
impl NodeRecord
Sourcepub fn from_secret_key(addr: SocketAddr, sk: &SecretKey) -> Self
Available on crate feature secp256k1
only.
pub fn from_secret_key(addr: SocketAddr, sk: &SecretKey) -> Self
secp256k1
only.Derive the NodeRecord
from the secret key and addr.
Note: this will set both the TCP and UDP ports to the port of the addr.
Sourcepub fn convert_ipv4_mapped(&mut self) -> bool
pub fn convert_ipv4_mapped(&mut self) -> bool
Converts the address
into an Ipv4Addr
if the address
is a mapped
Ipv6Addr
.
Returns true
if the address was converted.
See also std::net::Ipv6Addr::to_ipv4_mapped
Sourcepub fn into_ipv4_mapped(self) -> Self
pub fn into_ipv4_mapped(self) -> Self
Same as Self::convert_ipv4_mapped
but consumes the type
Sourcepub const fn with_tcp_port(self, port: u16) -> Self
pub const fn with_tcp_port(self, port: u16) -> Self
Sets the tcp port
Sourcepub const fn with_udp_port(self, port: u16) -> Self
pub const fn with_udp_port(self, port: u16) -> Self
Sets the udp port
Sourcepub const fn new(addr: SocketAddr, id: PeerId) -> Self
pub const fn new(addr: SocketAddr, id: PeerId) -> Self
Creates a new record from a socket addr and peer id.
Sourcepub fn new_with_ports(
ip_addr: IpAddr,
tcp_port: u16,
udp_port: Option<u16>,
id: PeerId,
) -> Self
pub fn new_with_ports( ip_addr: IpAddr, tcp_port: u16, udp_port: Option<u16>, id: PeerId, ) -> Self
Creates a new record from an ip address and ports.
Sourcepub const fn tcp_addr(&self) -> SocketAddr
pub const fn tcp_addr(&self) -> SocketAddr
The TCP socket address of this node
Sourcepub const fn udp_addr(&self) -> SocketAddr
pub const fn udp_addr(&self) -> SocketAddr
The UDP socket address of this node
Trait Implementations§
Source§impl Clone for NodeRecord
impl Clone for NodeRecord
Source§fn clone(&self) -> NodeRecord
fn clone(&self) -> NodeRecord
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for NodeRecord
impl Debug for NodeRecord
Source§impl Decodable for NodeRecord
impl Decodable for NodeRecord
Source§impl<'de> Deserialize<'de> for NodeRecord
impl<'de> Deserialize<'de> for NodeRecord
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 Display for NodeRecord
impl Display for NodeRecord
Source§impl Encodable for NodeRecord
impl Encodable for NodeRecord
Source§impl From<NodeRecord> for AnyNode
impl From<NodeRecord> for AnyNode
Source§fn from(value: NodeRecord) -> Self
fn from(value: NodeRecord) -> Self
Source§impl From<NodeRecord> for TrustedPeer
impl From<NodeRecord> for TrustedPeer
Source§fn from(record: NodeRecord) -> Self
fn from(record: NodeRecord) -> Self
Source§impl FromStr for NodeRecord
impl FromStr for NodeRecord
Source§impl Hash for NodeRecord
impl Hash for NodeRecord
Source§impl PartialEq for NodeRecord
impl PartialEq for NodeRecord
Source§impl Serialize for NodeRecordwhere
Self: Display,
impl Serialize for NodeRecordwhere
Self: Display,
Source§impl TryFrom<&Enr<SecretKey>> for NodeRecord
Available on crate feature secp256k1
only.
impl TryFrom<&Enr<SecretKey>> for NodeRecord
secp256k1
only.Source§impl TryFrom<Enr<SecretKey>> for NodeRecord
Available on crate feature secp256k1
only.
impl TryFrom<Enr<SecretKey>> for NodeRecord
secp256k1
only.impl Copy for NodeRecord
impl Eq for NodeRecord
impl StructuralPartialEq for NodeRecord
Auto Trait Implementations§
impl Freeze for NodeRecord
impl RefUnwindSafe for NodeRecord
impl Send for NodeRecord
impl Sync for NodeRecord
impl Unpin for NodeRecord
impl UnwindSafe for NodeRecord
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 86 bytes