move block contents to api crate, rename blob sidecars list

This commit is contained in:
realbigsean
2023-03-15 12:15:08 -04:00
parent 5887c8fe92
commit 3d99e1f14d
8 changed files with 75 additions and 81 deletions

View File

@@ -1,12 +1,12 @@
use lru::LruCache;
use parking_lot::Mutex;
use types::{BlobSidecars, EthSpec, Hash256};
use types::{BlobSidecarList, EthSpec, Hash256};
pub const DEFAULT_BLOB_CACHE_SIZE: usize = 10;
/// A cache blobs by beacon block root.
pub struct BlobCache<T: EthSpec> {
blobs: Mutex<LruCache<BlobCacheId, BlobSidecars<T>>>,
blobs: Mutex<LruCache<BlobCacheId, BlobSidecarList<T>>>,
}
#[derive(Hash, PartialEq, Eq)]
@@ -21,11 +21,15 @@ impl<T: EthSpec> Default for BlobCache<T> {
}
impl<T: EthSpec> BlobCache<T> {
pub fn put(&self, beacon_block: Hash256, blobs: BlobSidecars<T>) -> Option<BlobSidecars<T>> {
pub fn put(
&self,
beacon_block: Hash256,
blobs: BlobSidecarList<T>,
) -> Option<BlobSidecarList<T>> {
self.blobs.lock().put(BlobCacheId(beacon_block), blobs)
}
pub fn pop(&self, root: &Hash256) -> Option<BlobSidecars<T>> {
pub fn pop(&self, root: &Hash256) -> Option<BlobSidecarList<T>> {
self.blobs.lock().pop(&BlobCacheId(*root))
}
}