Skip to content

Commit 35aa090

Browse files
authored
chore: add helpers for beacon blob bundle (#1254)
1 parent 2443101 commit 35aa090

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

crates/rpc-types-beacon/src/sidecar.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,29 @@ use std::vec::IntoIter;
1010
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1111
pub struct BeaconBlobBundle {
1212
/// Vec of individual blob data
13-
data: Vec<BlobData>,
13+
pub data: Vec<BlobData>,
14+
}
15+
16+
impl BeaconBlobBundle {
17+
/// Creates a new [`BeaconBlobBundle`] from a given vector of [`BlobData`].
18+
pub const fn new(data: Vec<BlobData>) -> Self {
19+
Self { data }
20+
}
21+
22+
/// Returns the number of blobs in the bundle.
23+
pub fn len(&self) -> usize {
24+
self.data.len()
25+
}
26+
27+
/// Returns if the bundle is empty.
28+
pub fn is_empty(&self) -> bool {
29+
self.data.is_empty()
30+
}
31+
32+
/// Returns the blob with the given index.
33+
pub fn get_blob(&self, index: u64) -> Option<&BlobData> {
34+
self.data.iter().find(|blob| blob.index == index)
35+
}
1436
}
1537

1638
/// Yields an iterator for BlobData

0 commit comments

Comments
 (0)