diff --git a/Cargo.lock b/Cargo.lock index e391d9a..39d9c59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1067,7 +1067,6 @@ dependencies = [ "once_cell", "proxy_signature", "redis", - "rustc-hash", "serde", "serde_json", "sha3", @@ -1575,9 +1574,9 @@ dependencies = [ [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustc-hex" @@ -1881,9 +1880,12 @@ checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" [[package]] name = "timed-map" -version = "0.1.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589dc3ef6288d2afc0d355d82cc34b1894bfc85844c4d69b6607d4862181ded1" +checksum = "9d4e2e0c83d81123e086105a1f6389fdeefa0ba87923e42b4e747d92a5666acc" +dependencies = [ + "rustc-hash", +] [[package]] name = "tiny-keccak" diff --git a/Cargo.toml b/Cargo.toml index 523bc0e..3757a78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,12 +20,11 @@ log = "0.4.17" once_cell = "1.12.0" url = { version = "2.2.2", features = ["serde"] } redis = { version = "0.21.5", default-features = false, features = ["tokio-comp"] } -rustc-hash = "1.1.0" serde = "1.0.137" serde_json = { version = "1.0.81", features = ["preserve_order", "raw_value"] } sha3 = "0.9" simple_logger = "2.1.0" -timed-map = "0.1.0" +timed-map = { version = "1.1", features = ["rustc-hash"] } tokio = { version = "1.12.0", default-features = false, features = ["macros", "rt-multi-thread", "sync", "time"] } tokio-tungstenite = { version = "0.20.0", features = ["native-tls"] } # From our sources diff --git a/src/proxy/http/mod.rs b/src/proxy/http/mod.rs index 22511c4..cea2e4f 100644 --- a/src/proxy/http/mod.rs +++ b/src/proxy/http/mod.rs @@ -2,7 +2,7 @@ use hyper::{StatusCode, Uri}; use libp2p::PeerId; use proxy_signature::ProxySign; use std::{net::SocketAddr, str::FromStr, sync::LazyLock, time::Duration}; -use timed_map::{StdClock, TimedMap}; +use timed_map::{MapKind, StdClock, TimedMap}; use tokio::sync::Mutex; use crate::{ @@ -109,8 +109,9 @@ async fn peer_connection_healthcheck( // for 10 seconds without asking again. let know_peer_expiration = Duration::from_secs(cfg.peer_healthcheck_caching_secs); - static KNOWN_PEERS: LazyLock>> = - LazyLock::new(|| Mutex::new(TimedMap::new())); + static KNOWN_PEERS: LazyLock>> = LazyLock::new(|| { + Mutex::new(TimedMap::new_with_map_kind(MapKind::FxHashMap).expiration_tick_cap(25)) + }); let mut know_peers = KNOWN_PEERS.lock().await;