Skip to content

Commit

Permalink
bump timed-map (#27)
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan authored Oct 26, 2024
1 parent 88f4a38 commit 85c1bd7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/proxy/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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<Mutex<TimedMap<StdClock, PeerId, ()>>> =
LazyLock::new(|| Mutex::new(TimedMap::new()));
static KNOWN_PEERS: LazyLock<Mutex<TimedMap<StdClock, PeerId, ()>>> = LazyLock::new(|| {
Mutex::new(TimedMap::new_with_map_kind(MapKind::FxHashMap).expiration_tick_cap(25))
});

let mut know_peers = KNOWN_PEERS.lock().await;

Expand Down

0 comments on commit 85c1bd7

Please sign in to comment.