mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 21:34:46 +00:00
block and blob handling progress
This commit is contained in:
@@ -20,6 +20,7 @@ pub struct CacheItem<E: EthSpec> {
|
||||
* Values used to make the block available.
|
||||
*/
|
||||
block: Arc<SignedBeaconBlock<E>>,
|
||||
blobs: Option<Arc<BlobsSidecar<E>>>,
|
||||
proto_block: ProtoBlock,
|
||||
}
|
||||
|
||||
@@ -50,6 +51,7 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
|
||||
&self,
|
||||
beacon_block_root: Hash256,
|
||||
block: Arc<SignedBeaconBlock<E>>,
|
||||
blobs: Option<Arc<BlobsSidecar<E>>>,
|
||||
proto_block: ProtoBlock,
|
||||
state: &BeaconState<E>,
|
||||
spec: &ChainSpec,
|
||||
@@ -74,6 +76,7 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
|
||||
source,
|
||||
target,
|
||||
block,
|
||||
blobs,
|
||||
proto_block,
|
||||
};
|
||||
|
||||
@@ -155,6 +158,16 @@ impl<E: EthSpec> EarlyAttesterCache<E> {
|
||||
.map(|item| item.block.clone())
|
||||
}
|
||||
|
||||
/// Returns the blobs, if `block_root` matches the cached item.
|
||||
pub fn get_blobs(&self, block_root: Hash256) -> Option<Arc<BlobsSidecar<E>>> {
|
||||
self.item
|
||||
.read()
|
||||
.as_ref()
|
||||
.filter(|item| item.beacon_block_root == block_root)
|
||||
.map(|item| item.blobs.clone())
|
||||
.flatten()
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
||||
Reference in New Issue
Block a user