mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
move block contents to api crate, rename blob sidecars list
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user