Fix BlobsByRange by reverting PR6462 (#6526)

* Revert "Remove generic E from RequestId (#6462)"

This reverts commit 772929fae2.
This commit is contained in:
Michael Sproul
2024-10-21 23:42:51 +11:00
committed by GitHub
parent 56a9befaa1
commit 9aefb5539b
15 changed files with 68 additions and 69 deletions

View File

@@ -8,6 +8,7 @@ use ssz_derive::{Decode, Encode};
use ssz_types::{typenum::U256, VariableList};
use std::collections::BTreeMap;
use std::fmt::Display;
use std::marker::PhantomData;
use std::ops::Deref;
use std::sync::Arc;
use strum::IntoStaticStr;
@@ -93,19 +94,27 @@ pub struct Ping {
variant_attributes(derive(Clone, Debug, PartialEq, Serialize),)
)]
#[derive(Clone, Debug, PartialEq)]
pub struct MetadataRequest;
pub struct MetadataRequest<E: EthSpec> {
_phantom_data: PhantomData<E>,
}
impl MetadataRequest {
impl<E: EthSpec> MetadataRequest<E> {
pub fn new_v1() -> Self {
Self::V1(MetadataRequestV1 {})
Self::V1(MetadataRequestV1 {
_phantom_data: PhantomData,
})
}
pub fn new_v2() -> Self {
Self::V2(MetadataRequestV2 {})
Self::V2(MetadataRequestV2 {
_phantom_data: PhantomData,
})
}
pub fn new_v3() -> Self {
Self::V3(MetadataRequestV3 {})
Self::V3(MetadataRequestV3 {
_phantom_data: PhantomData,
})
}
}
@@ -315,14 +324,11 @@ pub struct BlobsByRangeRequest {
/// The number of slots from the start slot.
pub count: u64,
/// maximum number of blobs in a single block.
pub max_blobs_per_block: usize,
}
impl BlobsByRangeRequest {
pub fn max_blobs_requested(&self) -> u64 {
self.count.saturating_mul(self.max_blobs_per_block as u64)
pub fn max_blobs_requested<E: EthSpec>(&self) -> u64 {
self.count.saturating_mul(E::max_blobs_per_block() as u64)
}
}
@@ -338,7 +344,7 @@ pub struct DataColumnsByRangeRequest {
}
impl DataColumnsByRangeRequest {
pub fn max_requested(&self) -> u64 {
pub fn max_requested<E: EthSpec>(&self) -> u64 {
self.count.saturating_mul(self.columns.len() as u64)
}