add wrapper type
This commit is contained in:
parent
e962e80bb4
commit
4760dbb078
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user