mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 05:48:31 +00:00
add a bunch of blob coupling boiler plate, add a blobs by root request
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
use std::sync::Arc;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz::{Decode, DecodeError};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use tree_hash_derive::TreeHash;
|
||||
use crate::{BlobsSidecar, EthSpec, SignedBeaconBlock};
|
||||
use crate::{BlobsSidecar, EthSpec, SignedBeaconBlock, SignedBeaconBlockEip4844};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, PartialEq)]
|
||||
#[serde(bound = "T: EthSpec")]
|
||||
@@ -10,9 +12,26 @@ pub struct SignedBeaconBlockAndBlobsSidecar<T: EthSpec> {
|
||||
pub blobs_sidecar: BlobsSidecar<T>,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> SignedBeaconBlockAndBlobsSidecar<T> {
|
||||
/// SSZ decode with fork variant determined by slot.
|
||||
pub fn from_ssz_bytes(bytes: &[u8], spec: &ChainSpec) -> Result<Self, ssz::DecodeError> {
|
||||
SignedBeaconBlock::from_ssz_bytes(bytes, spec)
|
||||
impl <T: EthSpec>Decode for SignedBeaconBlockAndBlobsSidecar<T> {
|
||||
fn is_ssz_fixed_len() -> bool {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum BlockMaybeBlobs<T: EthSpec> {
|
||||
Block(Arc<SignedBeaconBlock<T>>),
|
||||
BlockAndBlobs(Arc<SignedBeaconBlockAndBlobsSidecar<T>>),
|
||||
}
|
||||
|
||||
impl <T: EthSpec> BlockMaybeBlobs<T> {
|
||||
pub fn blobs(&self) -> Option<&BlobsSidecar<T>>{
|
||||
match self {
|
||||
Self::Block(_) => None,
|
||||
Self::BlockAndBlobs(block_and_blobs) => Some(&block_and_blobs.blobs_sidecar)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user