pub struct CodedBlock<B: Block, C: Scheme, H: Hasher> { /* private fields */ }Expand description
An envelope type for an erasure coded Block.
The consensus commitment is fixed when the block is built, decoded, or restored, so reading the commitment or the inner block’s digest never hashes or erasure codes.
Implementations§
Source§impl<B: Block, C: Scheme, H: Hasher> CodedBlock<B, C, H>
impl<B: Block, C: Scheme, H: Hasher> CodedBlock<B, C, H>
Sourcepub const fn max_encode_size(application: usize) -> usize
pub const fn max_encode_size(application: usize) -> usize
Returns the largest encoded size of a coded block whose application block encodes to at
most application bytes.
Sourcepub fn precomputed(inner: Digested<B>, commitment: Commitment<B, C, H>) -> Self
pub fn precomputed(inner: Digested<B>, commitment: Commitment<B, C, H>) -> Self
Creates a CodedBlock from a Block and its precomputed Commitment.
commitment must encode inner. Self::shards generates shards on
demand and panics if the coding root does not match.
Panics if commitment does not commit to the block’s digest.
Sourcepub fn config(&self) -> CodingConfig
pub fn config(&self) -> CodingConfig
Returns the coding configuration for the data committed.
Sourcepub fn shards(&self, strategy: &impl Strategy) -> &[C::Shard]
pub fn shards(&self, strategy: &impl Strategy) -> &[C::Shard]
Returns a reference to the shards in this coded block.
If the shards have not yet been generated, they will be created via Scheme::encode.
Sourcepub fn shard(&self, index: u16) -> Option<Shard<B, C, H>>
pub fn shard(&self, index: u16) -> Option<Shard<B, C, H>>
Returns a Shard at the given index, if the index is valid.
Returns a shared reference to the inner Block.
Sourcepub fn inner_digested(&self) -> Digested<B>
pub fn inner_digested(&self) -> Digested<B>
Returns the inner Block with its digest, which the commitment binds.
Source§impl<B: CertifiableBlock, C: Scheme, H: Hasher> CodedBlock<B, C, H>
impl<B: CertifiableBlock, C: Scheme, H: Hasher> CodedBlock<B, C, H>
Sourcepub fn encode(
inner: Digested<B>,
config: CodingConfig,
strategy: &impl Strategy,
) -> impl Future<Output = Self> + Send + 'static
pub fn encode( inner: Digested<B>, config: CodingConfig, strategy: &impl Strategy, ) -> impl Future<Output = Self> + Send + 'static
Erasure codes inner with config as a job on strategy, producing a CodedBlock that
holds its shards.
Trait Implementations§
Source§impl<B: CertifiableBlock, C: Scheme, H: Hasher> CertifiableBlock for CodedBlock<B, C, H>
impl<B: CertifiableBlock, C: Scheme, H: Hasher> CertifiableBlock for CodedBlock<B, C, H>
Source§impl<B: Block, C: Scheme, H: Hasher> Committable for CodedBlock<B, C, H>
impl<B: Block, C: Scheme, H: Hasher> Committable for CodedBlock<B, C, H>
Source§type Commitment = Commitment<B, C, H>
type Commitment = Commitment<B, C, H>
Source§fn commitment(&self) -> Self::Commitment
fn commitment(&self) -> Self::Commitment
Source§impl<B: Block, C: Scheme, H: Hasher> Digestible for CodedBlock<B, C, H>
impl<B: Block, C: Scheme, H: Hasher> Digestible for CodedBlock<B, C, H>
Source§impl<B: Block, C: Scheme, H: Hasher> EncodeSize for CodedBlock<B, C, H>
impl<B: Block, C: Scheme, H: Hasher> EncodeSize for CodedBlock<B, C, H>
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Source§fn encode_inline_size(&self) -> usize
fn encode_inline_size(&self) -> usize
BufsMut::push
during Write::write_bufs. Used to size the fixed working buffer for
inline writes, so it must not be less than the bytes written inline.
Override alongside Write::write_bufs for types where large
byte fields go via push, or the working buffer will over-allocate.impl<B: Block + Eq, C: Scheme, H: Hasher> Eq for CodedBlock<B, C, H>
Source§impl<B: Block, C: Scheme, H: Hasher> From<CodedBlock<B, C, H>> for StoredCodedBlock<B, C, H>
impl<B: Block, C: Scheme, H: Hasher> From<CodedBlock<B, C, H>> for StoredCodedBlock<B, C, H>
Source§fn from(block: CodedBlock<B, C, H>) -> Self
fn from(block: CodedBlock<B, C, H>) -> Self
Source§impl<B: Block, C: Scheme, H: Hasher> From<StoredCodedBlock<B, C, H>> for CodedBlock<B, C, H>
Converts a StoredCodedBlock back to a CodedBlock.
impl<B: Block, C: Scheme, H: Hasher> From<StoredCodedBlock<B, C, H>> for CodedBlock<B, C, H>
Converts a StoredCodedBlock back to a CodedBlock.
Source§fn from(stored: StoredCodedBlock<B, C, H>) -> Self
fn from(stored: StoredCodedBlock<B, C, H>) -> Self
Source§impl<B: Block, C: Scheme, H: Hasher> Heightable for CodedBlock<B, C, H>
impl<B: Block, C: Scheme, H: Hasher> Heightable for CodedBlock<B, C, H>
Source§impl<B: Block, C: Scheme, H: Hasher> Write for CodedBlock<B, C, H>
impl<B: Block, C: Scheme, H: Hasher> Write for CodedBlock<B, C, H>
Source§fn write_bufs(&self, buf: &mut impl BufsMut)
fn write_bufs(&self, buf: &mut impl BufsMut)
BufsMut, allowing existing byte chunks to be
appended via BufsMut::push instead of written inline. Must encode
to the same format as Write::write. Defaults to Write::write.Auto Trait Implementations§
impl<B, C, H> !Freeze for CodedBlock<B, C, H>
impl<B, C, H> RefUnwindSafe for CodedBlock<B, C, H>where
Arc<B>: RefUnwindSafe,
Commitment<B, C, H>: RefUnwindSafe,
OnceLock<Arc<[<C as Scheme>::Shard]>>: RefUnwindSafe,
impl<B, C, H> Send for CodedBlock<B, C, H>
impl<B, C, H> Sync for CodedBlock<B, C, H>
impl<B, C, H> Unpin for CodedBlock<B, C, H>
impl<B, C, H> UnsafeUnpin for CodedBlock<B, C, H>where
Arc<B>: UnsafeUnpin,
Commitment<B, C, H>: UnsafeUnpin,
OnceLock<Arc<[<C as Scheme>::Shard]>>: UnsafeUnpin,
impl<B, C, H> UnwindSafe for CodedBlock<B, C, H>where
Arc<B>: UnwindSafe,
Commitment<B, C, H>: UnwindSafe,
OnceLock<Arc<[<C as Scheme>::Shard]>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encode for Twhere
T: Write + EncodeSize,
impl<T> Encode for Twhere
T: Write + EncodeSize,
Source§impl<T> EncodeExt for Twhere
T: EncodeSize + Write,
impl<T> EncodeExt for Twhere
T: EncodeSize + Write,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more