Import gossip data column into data availability checker (#6197)

* Import gossip data column into data availability checker
This commit is contained in:
Jimmy Chen
2024-08-02 22:42:11 +10:00
committed by GitHub
parent 0e96d4f105
commit acd3151184
8 changed files with 128 additions and 41 deletions

View File

@@ -22,6 +22,7 @@ pub struct CacheItem<E: EthSpec> {
*/
block: Arc<SignedBeaconBlock<E>>,
blobs: Option<BlobSidecarList<E>>,
data_columns: Option<DataColumnSidecarList<E>>,
proto_block: ProtoBlock,
}
@@ -69,7 +70,7 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
},
};
let (_, block, blobs) = block.deconstruct();
let (_, block, blobs, data_columns) = block.deconstruct();
let item = CacheItem {
epoch,
committee_lengths,
@@ -78,6 +79,7 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
target,
block,
blobs,
data_columns,
proto_block,
};
@@ -164,6 +166,15 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
.and_then(|item| item.blobs.clone())
}
/// Returns the data columns, if `block_root` matches the cached item.
pub fn get_data_columns(&self, block_root: Hash256) -> Option<DataColumnSidecarList<E>> {
self.item
.read()
.as_ref()
.filter(|item| item.beacon_block_root == block_root)
.and_then(|item| item.data_columns.clone())
}
/// Returns the proto-array block, if `block_root` matches the cached item.
pub fn get_proto_block(&self, block_root: Hash256) -> Option<ProtoBlock> {
self.item