From 21761ad497967382e4b90f80239f7dfaeb73f3c8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 20 Jan 2025 21:09:31 +0100 Subject: [PATCH] perf: check block cache for requested header (#13890) --- crates/rpc/rpc-eth-types/src/cache/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/rpc/rpc-eth-types/src/cache/mod.rs b/crates/rpc/rpc-eth-types/src/cache/mod.rs index ff2646cfc..1a39ce210 100644 --- a/crates/rpc/rpc-eth-types/src/cache/mod.rs +++ b/crates/rpc/rpc-eth-types/src/cache/mod.rs @@ -452,6 +452,12 @@ where continue } + // it's possible we have the entire block cached + if let Some(block) = this.full_block_cache.get(&block_hash) { + let _ = response_tx.send(Ok(block.clone_header())); + continue + } + // header is not in the cache, request it if this is the first // consumer if this.headers_cache.queue(block_hash, response_tx) {