add wrapper type

This commit is contained in:
Diva M 2022-11-28 14:22:19 -05:00
parent e962e80bb4
commit 4760dbb078
No known key found for this signature in database
GPG Key ID: 1BAE5E01126680FE

View File

@ -1,6 +1,6 @@
use crate::{BlobsSidecar, EthSpec, SignedBeaconBlock, SignedBeaconBlockEip4844};
use serde_derive::{Deserialize, Serialize};
use ssz::{Decode, DecodeError, Encode};
use ssz::{Decode, DecodeError};
use ssz_derive::{Decode, Encode};
use std::sync::Arc;
use tree_hash_derive::TreeHash;
@ -31,3 +31,22 @@ impl<T: EthSpec> SignedBeaconBlockAndBlobsSidecar<T> {
})
}
}
/// A wrapper over a [`SignedBeaconBlock`] or a [`SignedBeaconBlockAndBlobsSidecar`].
pub enum BlockWrapper<T: EthSpec> {
Block {
block: Arc<SignedBeaconBlock<T>>,
},
BlockAndBlob {
block_sidecar_pair: SignedBeaconBlockAndBlobsSidecar<T>,
},
}
impl<T: EthSpec> BlockWrapper<T> {
pub fn block(&self) -> &SignedBeaconBlock<T> {
match self {
BlockWrapper::Block { block } => &block,
BlockWrapper::BlockAndBlob { block_sidecar_pair } => &block_sidecar_pair.beacon_block,
}
}
}