Trait Block
pub trait Block:
Send
+ Sync
+ Unpin
+ Clone
+ Default
+ Debug
+ PartialEq
+ Eq
+ InMemorySize
+ MaybeSerde
+ Encodable
+ Decodable {
type Header: BlockHeader;
type Body: BlockBody<OmmerHeader = Self::Header>;
Show 16 methods
// Required methods
fn new(header: Self::Header, body: Self::Body) -> Self;
fn header(&self) -> &Self::Header;
fn body(&self) -> &Self::Body;
fn split(self) -> (Self::Header, Self::Body);
fn rlp_length(header: &Self::Header, body: &Self::Body) -> usize;
// Provided methods
fn new_sealed(
header: SealedHeader<Self::Header>,
body: Self::Body,
) -> SealedBlock<Self> { ... }
fn seal_unchecked(self, hash: FixedBytes<32>) -> SealedBlock<Self> { ... }
fn seal(self) -> SealedBlock<Self> { ... }
fn seal_slow(self) -> SealedBlock<Self> { ... }
fn split_ref(&self) -> (&Self::Header, &Self::Body) { ... }
fn into_header(self) -> Self::Header { ... }
fn into_body(self) -> Self::Body { ... }
fn recover_signers(&self) -> Result<Vec<Address>, RecoveryError>
where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... }
fn try_into_recovered_unchecked(
self,
senders: Vec<Address>,
) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>>
where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... }
fn into_recovered_with_signers(
self,
signers: Vec<Address>,
) -> RecoveredBlock<Self>
where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... }
fn try_into_recovered(
self,
) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>>
where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... }
}
Expand description
Abstraction of block data type.
This type defines the structure of a block in the blockchain.
A Block
is composed of a header and a body.
It is expected that a block can always be completely reconstructed from its header and body.
Required Associated Types§
type Header: BlockHeader
type Header: BlockHeader
Header part of the block.
Required Methods§
fn rlp_length(header: &Self::Header, body: &Self::Body) -> usize
fn rlp_length(header: &Self::Header, body: &Self::Body) -> usize
Returns the rlp length of the block with the given header and body.
Provided Methods§
fn new_sealed(
header: SealedHeader<Self::Header>,
body: Self::Body,
) -> SealedBlock<Self>
fn new_sealed( header: SealedHeader<Self::Header>, body: Self::Body, ) -> SealedBlock<Self>
Create new a sealed block instance from a sealed header and the block body.
fn seal_unchecked(self, hash: FixedBytes<32>) -> SealedBlock<Self>
fn seal_unchecked(self, hash: FixedBytes<32>) -> SealedBlock<Self>
Seal the block with a known hash.
WARNING: This method does not perform validation whether the hash is correct.
fn seal(self) -> SealedBlock<Self>
fn seal(self) -> SealedBlock<Self>
Creates the SealedBlock
from the block’s parts without calculating the hash upfront.
fn seal_slow(self) -> SealedBlock<Self>
fn seal_slow(self) -> SealedBlock<Self>
Calculate the header hash and seal the block so that it can’t be changed.
fn split_ref(&self) -> (&Self::Header, &Self::Body)
fn split_ref(&self) -> (&Self::Header, &Self::Body)
Returns a tuple of references to the block’s header and body.
fn into_header(self) -> Self::Header
fn into_header(self) -> Self::Header
Consumes the block and returns the header.
fn recover_signers(&self) -> Result<Vec<Address>, RecoveryError>
fn recover_signers(&self) -> Result<Vec<Address>, RecoveryError>
Expensive operation that recovers transaction signer.
fn try_into_recovered_unchecked(
self,
senders: Vec<Address>,
) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>>
fn try_into_recovered_unchecked( self, senders: Vec<Address>, ) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>>
Transform the block into a RecoveredBlock
using the given senders.
If the number of senders does not match the number of transactions in the block, this falls
back to manually recovery, but without ensuring that the signature has a low s
value.
Returns the block as error if a signature is invalid.
fn into_recovered_with_signers(
self,
signers: Vec<Address>,
) -> RecoveredBlock<Self>
fn into_recovered_with_signers( self, signers: Vec<Address>, ) -> RecoveredBlock<Self>
Transform the block into a RecoveredBlock
using the given signers.
Note: This method assumes the signers are correct and does not validate them.
fn try_into_recovered(
self,
) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>>
fn try_into_recovered( self, ) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>>
Expensive. Transform into a RecoveredBlock
by recovering senders in the contained
transactions.
Returns the block as error if a signature is invalid.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.