Skip to content

Commit

Permalink
Fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud10240 committed Dec 12, 2023
1 parent 81620d1 commit 5130695
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ async fn request_rpc(rpc_url: Url, body: &Value) -> anyhow::Result<Value> {
Ok(result)
}

fn read_cache(handler: &dyn RpcCacheHandler, params: &Value) -> anyhow::Result<CacheStatus> {
fn read_cache(
handler: &dyn RpcCacheHandler,
method: &str,
params: &Value,
) -> anyhow::Result<CacheStatus> {
let cache_key = handler
.extract_cache_key(params)
.context("fail to extract cache key")?;

let cache_key = match cache_key {
Some(cache_key) => cache_key,
Some(cache_key) => format!("{}:{}", method, cache_key),
None => return Ok(CacheStatus::NotAvailable),
};

Expand Down Expand Up @@ -145,7 +149,7 @@ async fn rpc_call(
}
};

let result = read_cache(cache_entry.handler.as_ref(), params);
let result = read_cache(cache_entry.handler.as_ref(), method, params);

match result {
Err(err) => {
Expand Down

0 comments on commit 5130695

Please sign in to comment.