Keep payload cache idempotent (#4256)

## Issue Addressed

[#4239](https://github.com/sigp/lighthouse/issues/4239)

## Proposed Changes

keep the payload cache entry intact after fetching it

## Additional Info
This commit is contained in:
Eitan Seri-Levi 2023-05-30 01:38:45 +00:00
parent c547a11b0d
commit 744b1950e5
2 changed files with 5 additions and 1 deletions

View File

@ -380,7 +380,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
/// Attempt to retrieve a full payload from the payload cache by the payload root /// Attempt to retrieve a full payload from the payload cache by the payload root
pub fn get_payload_by_root(&self, root: &Hash256) -> Option<ExecutionPayload<T>> { pub fn get_payload_by_root(&self, root: &Hash256) -> Option<ExecutionPayload<T>> {
self.inner.payload_cache.pop(root) self.inner.payload_cache.get(root)
} }
pub fn executor(&self) -> &TaskExecutor { pub fn executor(&self) -> &TaskExecutor {

View File

@ -30,4 +30,8 @@ impl<T: EthSpec> PayloadCache<T> {
pub fn pop(&self, root: &Hash256) -> Option<ExecutionPayload<T>> { pub fn pop(&self, root: &Hash256) -> Option<ExecutionPayload<T>> {
self.payloads.lock().pop(&PayloadCacheId(*root)) self.payloads.lock().pop(&PayloadCacheId(*root))
} }
pub fn get(&self, hash: &Hash256) -> Option<ExecutionPayload<T>> {
self.payloads.lock().get(&PayloadCacheId(*hash)).cloned()
}
} }