pub struct Addr {
pub ip: [u8; 16],
pub node_id: NodeId,
pub port: u16,
}Expand description
Addr combines a network endpoint (IP + port) with a cryptographic node identity.
The IP is stored internally as 16 bytes in IPv4-mapped IPv6 format
(::ffff:x.x.x.x) for IPv4 addresses; pure IPv6 addresses are stored as-is.
Use Addr::new_ipv4 / Addr::new_ipv6 to construct addresses from standard
Rust IP types, and Addr::encode / Addr::decode to convert to/from the
compact base58 wire format.
Fields§
§ip: [u8; 16]16-byte IP address in IPv4-mapped IPv6 form (::ffff:x.x.x.x for IPv4).
node_id: NodeIdThe 32-byte node identifier of the peer at this address.
port: u16UDP port number.
Implementations§
Source§impl Addr
impl Addr
Sourcepub fn new_ipv4(ipv4: Ipv4Addr, node_id: NodeId, port: u16) -> Self
pub fn new_ipv4(ipv4: Ipv4Addr, node_id: NodeId, port: u16) -> Self
new_ipv4 creates an Addr from an IPv4 address, storing it as IPv4-mapped IPv6.
Sourcepub fn new_ipv6(ipv6: Ipv6Addr, node_id: NodeId, port: u16) -> Self
pub fn new_ipv6(ipv6: Ipv6Addr, node_id: NodeId, port: u16) -> Self
new_ipv6 creates an Addr from a pure IPv6 address.
Sourcepub fn ip_addr(&self) -> IpAddr
pub fn ip_addr(&self) -> IpAddr
ip_addr returns the address as a standard IpAddr, converting IPv4-mapped IPv6 back to V4.