mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-03 17:54:28 +00:00
add wrapper type
This commit is contained in:
parent
e962e80bb4
commit
4760dbb078
@ -1,6 +1,6 @@
|
|||||||
use crate::{BlobsSidecar, EthSpec, SignedBeaconBlock, SignedBeaconBlockEip4844};
|
use crate::{BlobsSidecar, EthSpec, SignedBeaconBlock, SignedBeaconBlockEip4844};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use ssz::{Decode, DecodeError, Encode};
|
use ssz::{Decode, DecodeError};
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tree_hash_derive::TreeHash;
|
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