From 88661fa8650f2884a854721eab445f3f8f66171b Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sat, 10 Sep 2022 03:46:02 +0000 Subject: [PATCH] return UnknownKey instead of error --- web3_proxy/src/frontend/rate_limit.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web3_proxy/src/frontend/rate_limit.rs b/web3_proxy/src/frontend/rate_limit.rs index b5e2c022..e07cfb70 100644 --- a/web3_proxy/src/frontend/rate_limit.rs +++ b/web3_proxy/src/frontend/rate_limit.rs @@ -155,17 +155,16 @@ impl Web3ProxyApp { // if cache was empty, check the database // TODO: i think there is a cleaner way to do this - let user_data = if user_data.is_none() { - self.cache_user_data(user_key) + let user_data = match user_data { + None => self + .cache_user_data(user_key) .await - .context("no user data")? - } else { - // unwrap the cache's result - user_data.expect("we just checked the user_data is_none above") + .context("fetching user data for rate limits")?, + Some(user_data) => user_data, }; if user_data.user_id == 0 { - return Err(anyhow::anyhow!("unknown key!")); + return Ok(RateLimitResult::UnknownKey); } // user key is valid. now check rate limits