Skip to content

Commit

Permalink
EnrExt: rename quic to quic4 for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Aug 12, 2023
1 parent 68d3a84 commit fbdd015
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/src/discovery/enr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn compare_enr(local_enr: &Enr, disk_enr: &Enr) -> bool {
&& local_enr.tcp4() == disk_enr.tcp4()
&& local_enr.tcp6() == disk_enr.tcp6()
// quic ports must match
&& local_enr.quic() == disk_enr.quic()
&& local_enr.quic4() == disk_enr.quic4()
&& local_enr.quic6() == disk_enr.quic6()
// must match on the same fork
&& local_enr.get(ETH2_ENR_KEY) == disk_enr.get(ETH2_ENR_KEY)
Expand Down
10 changes: 5 additions & 5 deletions beacon_node/lighthouse_network/src/discovery/enr_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub trait EnrExt {
fn multiaddr_quic(&self) -> Vec<Multiaddr>;

/// Returns the quic port if one is set.
fn quic(&self) -> Option<u16>;
fn quic4(&self) -> Option<u16>;

/// Returns the quic6 port if one is set.
fn quic6(&self) -> Option<u16>;
Expand Down Expand Up @@ -62,7 +62,7 @@ impl EnrExt for Enr {
}

/// Returns the quic port if one is set.
fn quic(&self) -> Option<u16> {
fn quic4(&self) -> Option<u16> {
self.get_decodable(QUIC_ENR_KEY).and_then(Result::ok)
}

Expand All @@ -71,7 +71,7 @@ impl EnrExt for Enr {
self.get_decodable(QUIC6_ENR_KEY).and_then(Result::ok)
}

/// Returns a list of multiaddrs if the ENR has an `ip` and either a `tcp` or `udp` key **or** an `ip6` and either a `tcp6` or `udp6`.
/// Returns a list of multiaddrs if the ENR has an `ip` and either a `tcp`, `quic` or `udp` key **or** an `ip6` and either a `tcp6` `quic6` or `udp6`.
/// The vector remains empty if these fields are not defined.
fn multiaddr(&self) -> Vec<Multiaddr> {
let mut multiaddrs: Vec<Multiaddr> = Vec::new();
Expand All @@ -81,7 +81,7 @@ impl EnrExt for Enr {
multiaddr.push(Protocol::Udp(udp));
multiaddrs.push(multiaddr);
}
if let Some(quic) = self.quic() {
if let Some(quic) = self.quic4() {
let mut multiaddr: Multiaddr = ip.into();
multiaddr.push(Protocol::Udp(quic));
multiaddr.push(Protocol::QuicV1);
Expand Down Expand Up @@ -214,7 +214,7 @@ impl EnrExt for Enr {
fn multiaddr_quic(&self) -> Vec<Multiaddr> {
let mut multiaddrs: Vec<Multiaddr> = Vec::new();
// Check for quic first as it is less likely
if let Some(quic_port) = self.quic() {
if let Some(quic_port) = self.quic4() {
if let Some(ip) = self.ip4() {
let mut multiaddr: Multiaddr = ip.into();
multiaddr.push(Protocol::Udp(quic_port));
Expand Down

0 comments on commit fbdd015

Please sign in to comment.