mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 12:11:59 +00:00
thread blocks and blobs to sync (#4100)
* thread blocks and blobs to sync * satisfy dead code analysis
This commit is contained in:
@@ -75,20 +75,20 @@ pub struct SyncNetworkContext<T: BeaconChainTypes> {
|
||||
}
|
||||
|
||||
/// Small enumeration to make dealing with block and blob requests easier.
|
||||
pub enum BlockOrBlobs<T: EthSpec> {
|
||||
pub enum BlockOrBlob<T: EthSpec> {
|
||||
Block(Option<Arc<SignedBeaconBlock<T>>>),
|
||||
Blobs(Option<Arc<BlobSidecar<T>>>),
|
||||
Sidecar(Option<Arc<BlobSidecar<T>>>),
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<Option<Arc<SignedBeaconBlock<T>>>> for BlockOrBlobs<T> {
|
||||
impl<T: EthSpec> From<Option<Arc<SignedBeaconBlock<T>>>> for BlockOrBlob<T> {
|
||||
fn from(block: Option<Arc<SignedBeaconBlock<T>>>) -> Self {
|
||||
BlockOrBlobs::Block(block)
|
||||
BlockOrBlob::Block(block)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> From<Option<Arc<BlobSidecar<T>>>> for BlockOrBlobs<T> {
|
||||
impl<T: EthSpec> From<Option<Arc<BlobSidecar<T>>>> for BlockOrBlob<T> {
|
||||
fn from(blob: Option<Arc<BlobSidecar<T>>>) -> Self {
|
||||
BlockOrBlobs::Blobs(blob)
|
||||
BlockOrBlob::Sidecar(blob)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,15 +311,15 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
pub fn range_sync_block_and_blob_response(
|
||||
&mut self,
|
||||
request_id: Id,
|
||||
block_or_blob: BlockOrBlobs<T::EthSpec>,
|
||||
block_or_blob: BlockOrBlob<T::EthSpec>,
|
||||
) -> Option<(ChainId, BlocksAndBlobsByRangeResponse<T::EthSpec>)> {
|
||||
match self.range_blocks_and_blobs_requests.entry(request_id) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
let req = entry.get_mut();
|
||||
let info = &mut req.block_blob_info;
|
||||
match block_or_blob {
|
||||
BlockOrBlobs::Block(maybe_block) => info.add_block_response(maybe_block),
|
||||
BlockOrBlobs::Blobs(maybe_sidecar) => info.add_sidecar_response(maybe_sidecar),
|
||||
BlockOrBlob::Block(maybe_block) => info.add_block_response(maybe_block),
|
||||
BlockOrBlob::Sidecar(maybe_sidecar) => info.add_sidecar_response(maybe_sidecar),
|
||||
}
|
||||
if info.is_finished() {
|
||||
// If the request is finished, dequeue everything
|
||||
@@ -402,14 +402,14 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
pub fn backfill_sync_block_and_blob_response(
|
||||
&mut self,
|
||||
request_id: Id,
|
||||
block_or_blob: BlockOrBlobs<T::EthSpec>,
|
||||
block_or_blob: BlockOrBlob<T::EthSpec>,
|
||||
) -> Option<BlocksAndBlobsByRangeResponse<T::EthSpec>> {
|
||||
match self.backfill_blocks_and_blobs_requests.entry(request_id) {
|
||||
Entry::Occupied(mut entry) => {
|
||||
let (_, info) = entry.get_mut();
|
||||
match block_or_blob {
|
||||
BlockOrBlobs::Block(maybe_block) => info.add_block_response(maybe_block),
|
||||
BlockOrBlobs::Blobs(maybe_sidecar) => info.add_sidecar_response(maybe_sidecar),
|
||||
BlockOrBlob::Block(maybe_block) => info.add_block_response(maybe_block),
|
||||
BlockOrBlob::Sidecar(maybe_sidecar) => info.add_sidecar_response(maybe_sidecar),
|
||||
}
|
||||
if info.is_finished() {
|
||||
// If the request is finished, dequeue everything
|
||||
|
||||
Reference in New Issue
Block a user