mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 05:44:44 +00:00
Ensure lookup sync checks caches correctly (#5840)
* Ensure lookup sync checks caches correctly * fix tests and remove unused method * Simplify BlockProcessStatus
This commit is contained in:
@@ -44,7 +44,7 @@ use ssz_types::{FixedVector, VariableList};
|
||||
use std::num::NonZeroUsize;
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
use types::blob_sidecar::BlobIdentifier;
|
||||
use types::{BlobSidecar, ChainSpec, Epoch, EthSpec, Hash256};
|
||||
use types::{BlobSidecar, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock};
|
||||
|
||||
/// This represents the components of a partially available block
|
||||
///
|
||||
@@ -544,12 +544,19 @@ impl<T: BeaconChainTypes> OverflowLRUCache<T> {
|
||||
}
|
||||
|
||||
/// Returns true if the block root is known, without altering the LRU ordering
|
||||
pub fn has_execution_valid_block(&self, block_root: &Hash256) -> bool {
|
||||
if let Some(pending_components) = self.critical.read().peek_pending_components(block_root) {
|
||||
pending_components.executed_block.is_some()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
pub fn get_execution_valid_block(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
) -> Option<Arc<SignedBeaconBlock<T::EthSpec>>> {
|
||||
self.critical
|
||||
.read()
|
||||
.peek_pending_components(block_root)
|
||||
.and_then(|pending_components| {
|
||||
pending_components
|
||||
.executed_block
|
||||
.as_ref()
|
||||
.map(|block| block.block_cloned())
|
||||
})
|
||||
}
|
||||
|
||||
/// Fetch a blob from the cache without affecting the LRU ordering
|
||||
|
||||
@@ -37,6 +37,10 @@ impl<E: EthSpec> DietAvailabilityPendingExecutedBlock<E> {
|
||||
&self.block
|
||||
}
|
||||
|
||||
pub fn block_cloned(&self) -> Arc<SignedBeaconBlock<E>> {
|
||||
self.block.clone()
|
||||
}
|
||||
|
||||
pub fn num_blobs_expected(&self) -> usize {
|
||||
self.block
|
||||
.message()
|
||||
|
||||
Reference in New Issue
Block a user