mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 22:38:34 +00:00
Add sync lookup custody request state (#6257)
* Add sync lookup custody request state * Review PR * clippy * Merge branch 'unstable' of https://github.com/sigp/lighthouse into peerdas-network-lookup
This commit is contained in:
@@ -6852,6 +6852,24 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
self.data_availability_checker.data_availability_boundary()
|
||||
}
|
||||
|
||||
/// Returns true if epoch is within the data availability boundary
|
||||
pub fn da_check_required_for_epoch(&self, epoch: Epoch) -> bool {
|
||||
self.data_availability_checker
|
||||
.da_check_required_for_epoch(epoch)
|
||||
}
|
||||
|
||||
/// Returns true if we should fetch blobs for this block
|
||||
pub fn should_fetch_blobs(&self, block_epoch: Epoch) -> bool {
|
||||
self.da_check_required_for_epoch(block_epoch)
|
||||
&& !self.spec.is_peer_das_enabled_for_epoch(block_epoch)
|
||||
}
|
||||
|
||||
/// Returns true if we should fetch custody columns for this block
|
||||
pub fn should_fetch_custody_columns(&self, block_epoch: Epoch) -> bool {
|
||||
self.da_check_required_for_epoch(block_epoch)
|
||||
&& self.spec.is_peer_das_enabled_for_epoch(block_epoch)
|
||||
}
|
||||
|
||||
pub fn logger(&self) -> &Logger {
|
||||
&self.log
|
||||
}
|
||||
|
||||
@@ -156,6 +156,15 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the set of imported custody column indexes for `block_root`. Returns None if there is
|
||||
/// no block component for `block_root`.
|
||||
pub fn imported_custody_column_indexes(&self, block_root: &Hash256) -> Option<Vec<u64>> {
|
||||
self.availability_cache
|
||||
.peek_pending_components(block_root, |components| {
|
||||
components.map(|components| components.get_cached_data_columns_indices())
|
||||
})
|
||||
}
|
||||
|
||||
/// Get a blob from the availability cache.
|
||||
pub fn get_blob(
|
||||
&self,
|
||||
|
||||
@@ -13,7 +13,7 @@ use ssz_types::{FixedVector, VariableList};
|
||||
use std::num::NonZeroUsize;
|
||||
use std::sync::Arc;
|
||||
use types::blob_sidecar::BlobIdentifier;
|
||||
use types::{BlobSidecar, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock};
|
||||
use types::{BlobSidecar, ChainSpec, ColumnIndex, Epoch, EthSpec, Hash256, SignedBeaconBlock};
|
||||
|
||||
/// This represents the components of a partially available block
|
||||
///
|
||||
@@ -108,6 +108,14 @@ impl<E: EthSpec> PendingComponents<E> {
|
||||
self.verified_data_columns.len()
|
||||
}
|
||||
|
||||
/// Returns the indices of cached custody columns
|
||||
pub fn get_cached_data_columns_indices(&self) -> Vec<ColumnIndex> {
|
||||
self.verified_data_columns
|
||||
.iter()
|
||||
.map(|d| d.index())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Inserts a block into the cache.
|
||||
pub fn insert_block(&mut self, block: DietAvailabilityPendingExecutedBlock<E>) {
|
||||
*self.get_cached_block_mut() = Some(block)
|
||||
|
||||
Reference in New Issue
Block a user