mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(net/peer): add peer with udp socket (#9156)
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
@ -92,6 +92,17 @@ impl NodeRecord {
|
||||
Self { address: addr.ip(), tcp_port: addr.port(), udp_port: addr.port(), id }
|
||||
}
|
||||
|
||||
/// Creates a new record from an ip address and ports.
|
||||
pub fn new_with_ports(
|
||||
ip_addr: IpAddr,
|
||||
tcp_port: u16,
|
||||
udp_port: Option<u16>,
|
||||
id: PeerId,
|
||||
) -> Self {
|
||||
let udp_port = udp_port.unwrap_or(tcp_port);
|
||||
Self { address: ip_addr, tcp_port, udp_port, id }
|
||||
}
|
||||
|
||||
/// The TCP socket address of this node
|
||||
#[must_use]
|
||||
pub const fn tcp_addr(&self) -> SocketAddr {
|
||||
|
||||
Reference in New Issue
Block a user