period instead of minute in variable names

This commit is contained in:
Bryan Stitt 2022-11-01 19:24:29 +00:00
parent bb9e4f99ef
commit f859ed56fc
7 changed files with 12 additions and 11 deletions

7
Cargo.lock generated
View File

@ -2698,9 +2698,9 @@ dependencies = [
[[package]] [[package]]
name = "moka" name = "moka"
version = "0.9.4" version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8256cf9fa396576521e5e94affadb95818ec48f5dbedca36714387688aea29" checksum = "e013c8176e5aae43f4c0a982733c44feebddc4e7ac0871a109a9655e668487af"
dependencies = [ dependencies = [
"async-io", "async-io",
"async-lock", "async-lock",
@ -2711,6 +2711,7 @@ dependencies = [
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"rustc_version",
"scheduled-thread-pool", "scheduled-thread-pool",
"skeptic", "skeptic",
"smallvec", "smallvec",
@ -5527,7 +5528,7 @@ dependencies = [
[[package]] [[package]]
name = "web3_proxy" name = "web3_proxy"
version = "0.6.0" version = "0.8.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",

View File

@ -18,12 +18,12 @@ redirect_user_url = "https://llamanodes.com/user-rpc-stats/{{user_id}}"
# 0 = block all public requests # 0 = block all public requests
public_max_concurrent_requests = 5 public_max_concurrent_requests = 5
# 0 = block all public requests # 0 = block all public requests
public_requests_per_minute = 0 public_requests_per_period = 0
# 1GB of cache # 1GB of cache
response_cache_max_bytes = 10_000_000_000 response_cache_max_bytes = 10_000_000_000
[app.allowed_origin_requests_per_minute] [app.allowed_origin_requests_per_period]
"https://chainlist.org" = 1_000 "https://chainlist.org" = 1_000
[balanced_rpcs] [balanced_rpcs]

View File

@ -9,6 +9,6 @@ redis-rate-limiter = { path = "../redis-rate-limiter" }
anyhow = "1.0.66" anyhow = "1.0.66"
hashbrown = "0.12.3" hashbrown = "0.12.3"
moka = { version = "0.9.4", default-features = false, features = ["future"] } moka = { version = "0.9.5", default-features = false, features = ["future"] }
tokio = "1.21.2" tokio = "1.21.2"
tracing = "0.1.37" tracing = "0.1.37"

View File

@ -77,7 +77,6 @@ where
let redis_key = format!("{}:{}", self.prefix, key); let redis_key = format!("{}:{}", self.prefix, key);
// TODO: DO NOT UNWRAP HERE. figure out how to handle anyhow error being wrapped in an Arc
// TODO: i'm sure this could be a lot better. but race conditions make this hard to think through. brain needs sleep // TODO: i'm sure this could be a lot better. but race conditions make this hard to think through. brain needs sleep
let local_key_count: Arc<AtomicU64> = { let local_key_count: Arc<AtomicU64> = {
// clone things outside of the `async move` // clone things outside of the `async move`

View File

@ -1,6 +1,6 @@
[package] [package]
name = "web3_proxy" name = "web3_proxy"
version = "0.6.0" version = "0.8.0"
edition = "2021" edition = "2021"
default-run = "web3_proxy" default-run = "web3_proxy"
@ -39,7 +39,7 @@ hdrhistogram = "7.5.2"
http = "0.2.8" http = "0.2.8"
ipnet = "2.5.0" ipnet = "2.5.0"
metered = { version = "0.9.0", features = ["serialize"] } metered = { version = "0.9.0", features = ["serialize"] }
moka = { version = "0.9.4", default-features = false, features = ["future"] } moka = { version = "0.9.5", default-features = false, features = ["future"] }
notify = "5.0.0" notify = "5.0.0"
num = "0.4.0" num = "0.4.0"
# TODO: import num_traits from sea-orm so we always have the same version # TODO: import num_traits from sea-orm so we always have the same version

View File

@ -348,9 +348,10 @@ impl StatEmitter {
debug_assert_eq!(stat.period_seconds, self.period_seconds); debug_assert_eq!(stat.period_seconds, self.period_seconds);
// get the user cache for the current period // get the user cache for the current period
// TODO: i don't think this works right. maybe do DashMap entry api as the outer variable
let user_cache = self let user_cache = self
.aggregated_proxy_responses .aggregated_proxy_responses
.get_with(stat.period_timestamp, async move { .get_with_by_ref(&stat.period_timestamp, async move {
CacheBuilder::default() CacheBuilder::default()
.build_with_hasher(hashbrown::hash_map::DefaultHashBuilder::new()) .build_with_hasher(hashbrown::hash_map::DefaultHashBuilder::new())
}) })

View File

@ -384,7 +384,7 @@ impl Web3Connection {
// if we already have this block saved, set new_head_block to that arc. otherwise store this copy // if we already have this block saved, set new_head_block to that arc. otherwise store this copy
new_head_block = block_map new_head_block = block_map
.get_with(new_hash, async move { new_head_block }) .get_with_by_ref(&new_hash, async move { new_head_block })
.await; .await;
let new_num = new_head_block.number.unwrap_or_default(); let new_num = new_head_block.number.unwrap_or_default();