Skip to content

Commit

Permalink
chore: remove semicolons
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Oct 29, 2024
1 parent d5a5fcc commit 2841fc6
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions crates/net/discv4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ impl Discv4Service {
let Some(bucket) = self.kbuckets.get_bucket(&key) else { return false };
if bucket.num_entries() < MAX_NODES_PER_BUCKET / 2 {
// skip half empty bucket
return false;
return false
}
self.remove_key(node_id, key)
}
Expand All @@ -885,7 +885,7 @@ impl Discv4Service {
fn has_bond(&self, remote_id: PeerId, remote_ip: IpAddr) -> bool {
if let Some(timestamp) = self.received_pongs.last_pong(remote_id, remote_ip) {
if timestamp.elapsed() < self.config.bond_expiration {
return true;
return true
}
}
false
Expand All @@ -912,7 +912,7 @@ impl Discv4Service {
/// a followup request to retrieve the updated ENR
fn update_on_reping(&mut self, record: NodeRecord, mut last_enr_seq: Option<u64>) {
if record.id == self.local_node_record.id {
return;
return
}

// If EIP868 extension is disabled then we want to ignore this
Expand Down Expand Up @@ -947,7 +947,7 @@ impl Discv4Service {
/// Callback invoked when we receive a pong from the peer.
fn update_on_pong(&mut self, record: NodeRecord, mut last_enr_seq: Option<u64>) {
if record.id == *self.local_peer_id() {
return;
return
}

// If EIP868 extension is disabled then we want to ignore this
Expand Down Expand Up @@ -1056,7 +1056,7 @@ impl Discv4Service {
fn on_ping(&mut self, ping: Ping, remote_addr: SocketAddr, remote_id: PeerId, hash: B256) {
if self.is_expired(ping.expire) {
// ping's expiration timestamp is in the past
return;
return
}

// create the record
Expand Down Expand Up @@ -1188,17 +1188,17 @@ impl Discv4Service {
fn try_ping(&mut self, node: NodeRecord, reason: PingReason) {
if node.id == *self.local_peer_id() {
// don't ping ourselves
return;
return
}

if self.pending_pings.contains_key(&node.id) ||
self.pending_find_nodes.contains_key(&node.id)
{
return;
return
}

if self.queued_pings.iter().any(|(n, _)| n.id == node.id) {
return;
return
}

if self.pending_pings.len() < MAX_NODES_PING {
Expand Down Expand Up @@ -1233,7 +1233,7 @@ impl Discv4Service {
/// Returns the echo hash of the ping message.
pub(crate) fn send_enr_request(&mut self, node: NodeRecord) {
if !self.config.enable_eip868 {
return;
return
}
let remote_addr = node.udp_addr();
let enr_request = EnrRequest { expire: self.enr_request_expiration() };
Expand All @@ -1248,7 +1248,7 @@ impl Discv4Service {
/// Message handler for an incoming `Pong`.
fn on_pong(&mut self, pong: Pong, remote_addr: SocketAddr, remote_id: PeerId) {
if self.is_expired(pong.expire) {
return;
return
}

let PingRequest { node, reason, .. } = match self.pending_pings.entry(remote_id) {
Expand All @@ -1257,7 +1257,7 @@ impl Discv4Service {
let request = entry.get();
if request.echo_hash != pong.echo {
trace!(target: "discv4", from=?remote_addr, expected=?request.echo_hash, echo_hash=?pong.echo,"Got unexpected Pong");
return;
return
}
}
entry.remove()
Expand Down Expand Up @@ -1294,11 +1294,11 @@ impl Discv4Service {
fn on_find_node(&mut self, msg: FindNode, remote_addr: SocketAddr, node_id: PeerId) {
if self.is_expired(msg.expire) {
// expiration timestamp is in the past
return;
return
}
if node_id == *self.local_peer_id() {
// ignore find node requests to ourselves
return;
return
}

if self.has_bond(node_id, remote_addr.ip()) {
Expand All @@ -1313,7 +1313,7 @@ impl Discv4Service {
// ensure the ENR's public key matches the expected node id
let enr_id = pk2id(&msg.enr.public_key());
if id != enr_id {
return;
return
}

if resp.echo_hash == msg.request_hash {
Expand Down Expand Up @@ -1352,7 +1352,7 @@ impl Discv4Service {
request_hash: B256,
) {
if !self.config.enable_eip868 || self.is_expired(msg.expire) {
return;
return
}

if self.has_bond(id, remote_addr.ip()) {
Expand All @@ -1371,7 +1371,7 @@ impl Discv4Service {
fn on_neighbours(&mut self, msg: Neighbours, remote_addr: SocketAddr, node_id: PeerId) {
if self.is_expired(msg.expire) {
// response is expired
return;
return
}
// check if this request was expected
let ctx = match self.pending_find_nodes.entry(node_id) {
Expand All @@ -1387,7 +1387,7 @@ impl Discv4Service {
request.response_count = total;
} else {
trace!(target: "discv4", total, from=?remote_addr, "Received neighbors packet entries exceeds max nodes per bucket");
return;
return
}
};

Expand All @@ -1403,7 +1403,7 @@ impl Discv4Service {
Entry::Vacant(_) => {
// received neighbours response without requesting it
trace!(target: "discv4", from=?remote_addr, "Received unsolicited Neighbours");
return;
return
}
};

Expand All @@ -1423,7 +1423,7 @@ impl Discv4Service {
// prevent banned peers from being added to the context
if self.config.ban_list.is_banned(&node.id, &node.address) {
trace!(target: "discv4", peer_id=?node.id, ip=?node.address, "ignoring banned record");
continue;
continue
}

ctx.add_node(node);
Expand Down Expand Up @@ -1519,7 +1519,7 @@ impl Discv4Service {
self.pending_pings.retain(|node_id, ping_request| {
if now.duration_since(ping_request.sent_at) > self.config.ping_expiration {
failed_pings.push(*node_id);
return false;
return false
}
true
});
Expand All @@ -1536,7 +1536,7 @@ impl Discv4Service {
self.pending_lookup.retain(|node_id, (lookup_sent_at, _)| {
if now.duration_since(*lookup_sent_at) > self.config.request_timeout {
failed_lookups.push(*node_id);
return false;
return false
}
true
});
Expand All @@ -1562,13 +1562,13 @@ impl Discv4Service {
// treat this as an hard error since it responded.
failed_find_nodes.push(*node_id);
}
return false;
return false
}
true
});

if failed_find_nodes.is_empty() {
return;
return
}

trace!(target: "discv4", num=%failed_find_nodes.len(), "processing failed find nodes");
Expand Down Expand Up @@ -1635,7 +1635,7 @@ impl Discv4Service {
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs();
if self.config.enforce_expiration_timestamps && timestamp < now {
trace!(target: "discv4", "Expired packet");
return Err(());
return Err(())
}
Ok(())
}
Expand Down Expand Up @@ -1679,7 +1679,7 @@ impl Discv4Service {
loop {
// drain buffered events first
if let Some(event) = self.queued_events.pop_front() {
return Poll::Ready(event);
return Poll::Ready(event)
}

// trigger self lookup
Expand Down Expand Up @@ -1804,7 +1804,7 @@ impl Discv4Service {
// this will make sure we're woken up again
cx.waker().wake_by_ref();
}
break;
break
}
}

Expand All @@ -1822,7 +1822,7 @@ impl Discv4Service {
}

if self.queued_events.is_empty() {
return Poll::Pending;
return Poll::Pending
}
}
}
Expand Down Expand Up @@ -1929,7 +1929,7 @@ pub(crate) async fn receive_loop(udp: Arc<UdpSocket>, tx: IngressSender, local_i
// rate limit incoming packets by IP
if cache.inc_ip(remote_addr.ip()) > MAX_INCOMING_PACKETS_PER_MINUTE_BY_IP {
trace!(target: "discv4", ?remote_addr, "Too many incoming packets from IP.");
continue;
continue
}

let packet = &buf[..read];
Expand All @@ -1938,13 +1938,13 @@ pub(crate) async fn receive_loop(udp: Arc<UdpSocket>, tx: IngressSender, local_i
if packet.node_id == local_id {
// received our own message
debug!(target: "discv4", ?remote_addr, "Received own packet.");
continue;
continue
}

// skip if we've already received the same packet
if cache.contains_packet(packet.hash) {
debug!(target: "discv4", ?remote_addr, "Received duplicate packet.");
continue;
continue
}

send(IngressEvent::Packet(remote_addr, packet)).await;
Expand Down Expand Up @@ -2093,7 +2093,7 @@ impl LookupTargetRotator {
self.counter += 1;
self.counter %= self.interval;
if self.counter == 0 {
return *local;
return *local
}
PeerId::random()
}
Expand Down Expand Up @@ -2467,7 +2467,7 @@ mod tests {
assert!(service.pending_pings.contains_key(&node.id));
assert_eq!(service.pending_pings.len(), num_inserted);
if num_inserted == MAX_NODES_PING {
break;
break
}
}
}
Expand Down

0 comments on commit 2841fc6

Please sign in to comment.