mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Revert "renames, remove , wrap BlockWrapper enum to make descontruction private"
This reverts commit 5b3b34a9d7.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
use std::{collections::VecDeque, sync::Arc};
|
||||
|
||||
use types::{signed_block_and_blobs::BlockWrapper, BlobsSidecar, EthSpec, SignedBeaconBlock};
|
||||
use types::{
|
||||
signed_block_and_blobs::BlockWrapper, BlobsSidecar, EthSpec, SignedBeaconBlock,
|
||||
SignedBeaconBlockAndBlobsSidecar,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct BlocksAndBlobsRequestInfo<T: EthSpec> {
|
||||
pub struct BlockBlobRequestInfo<T: EthSpec> {
|
||||
/// Blocks we have received awaiting for their corresponding sidecar.
|
||||
accumulated_blocks: VecDeque<Arc<SignedBeaconBlock<T>>>,
|
||||
/// Sidecars we have received awaiting for their corresponding block.
|
||||
@@ -14,7 +17,7 @@ pub struct BlocksAndBlobsRequestInfo<T: EthSpec> {
|
||||
is_sidecars_stream_terminated: bool,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> BlocksAndBlobsRequestInfo<T> {
|
||||
impl<T: EthSpec> BlockBlobRequestInfo<T> {
|
||||
pub fn add_block_response(&mut self, maybe_block: Option<Arc<SignedBeaconBlock<T>>>) {
|
||||
match maybe_block {
|
||||
Some(block) => self.accumulated_blocks.push_back(block),
|
||||
@@ -30,7 +33,7 @@ impl<T: EthSpec> BlocksAndBlobsRequestInfo<T> {
|
||||
}
|
||||
|
||||
pub fn into_responses(self) -> Result<Vec<BlockWrapper<T>>, &'static str> {
|
||||
let BlocksAndBlobsRequestInfo {
|
||||
let BlockBlobRequestInfo {
|
||||
accumulated_blocks,
|
||||
mut accumulated_sidecars,
|
||||
..
|
||||
@@ -48,9 +51,14 @@ impl<T: EthSpec> BlocksAndBlobsRequestInfo<T> {
|
||||
{
|
||||
let blobs_sidecar =
|
||||
accumulated_sidecars.pop_front().ok_or("missing sidecar")?;
|
||||
Ok(BlockWrapper::new_with_blobs(beacon_block, blobs_sidecar))
|
||||
Ok(BlockWrapper::BlockAndBlob(
|
||||
SignedBeaconBlockAndBlobsSidecar {
|
||||
beacon_block,
|
||||
blobs_sidecar,
|
||||
},
|
||||
))
|
||||
} else {
|
||||
Ok(beacon_block.into())
|
||||
Ok(BlockWrapper::Block(beacon_block))
|
||||
}
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>();
|
||||
|
||||
Reference in New Issue
Block a user