pub struct BlockV1 { /* private fields */ }Expand description
A block after execution, with the resulting global state root hash. This is the core component of the Casper linear blockchain. Version 1.
Implementations§
Source§impl BlockV1
impl BlockV1
Sourcepub fn header(&self) -> &BlockHeaderV1
pub fn header(&self) -> &BlockHeaderV1
Returns the block’s header.
Sourcepub fn take_header(self) -> BlockHeaderV1
pub fn take_header(self) -> BlockHeaderV1
Returns the block’s header, consuming self.
Sourcepub fn body(&self) -> &BlockBodyV1
pub fn body(&self) -> &BlockBodyV1
Returns the block’s body.
Sourcepub fn take_body(self) -> BlockBodyV1
pub fn take_body(self) -> BlockBodyV1
Returns the block’s body, consuming self.
Sourcepub fn parent_hash(&self) -> &BlockHash
pub fn parent_hash(&self) -> &BlockHash
Returns the parent block’s hash.
Sourcepub fn state_root_hash(&self) -> &Digest
pub fn state_root_hash(&self) -> &Digest
Returns the root hash of global state after the deploys in this block have been executed.
Sourcepub fn random_bit(&self) -> bool
pub fn random_bit(&self) -> bool
Returns a random bit needed for initializing a future era.
Sourcepub fn accumulated_seed(&self) -> &Digest
pub fn accumulated_seed(&self) -> &Digest
Returns a seed needed for initializing a future era.
Sourcepub fn era_end(&self) -> Option<&EraEndV1>
pub fn era_end(&self) -> Option<&EraEndV1>
Returns the EraEnd of a block if it is a switch block.
Sourcepub fn protocol_version(&self) -> ProtocolVersion
pub fn protocol_version(&self) -> ProtocolVersion
Returns the protocol version of the network from when this block was created.
Sourcepub fn is_switch_block(&self) -> bool
pub fn is_switch_block(&self) -> bool
Returns true if this block is the last one in the current era.
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Returns true if this block is the Genesis block, i.e. has height 0 and era 0.
Sourcepub fn proposer(&self) -> &PublicKey
pub fn proposer(&self) -> &PublicKey
Returns the public key of the validator which proposed the block.
Sourcepub fn deploy_hashes(&self) -> &[DeployHash]
pub fn deploy_hashes(&self) -> &[DeployHash]
Returns the deploy hashes within the block.
Sourcepub fn transfer_hashes(&self) -> &[DeployHash]
pub fn transfer_hashes(&self) -> &[DeployHash]
Returns the transfer hashes within the block.
Sourcepub fn deploy_and_transfer_hashes(&self) -> impl Iterator<Item = &DeployHash>
pub fn deploy_and_transfer_hashes(&self) -> impl Iterator<Item = &DeployHash>
Returns the deploy and transfer hashes in the order in which they were executed.
Sourcepub fn verify(&self) -> Result<(), BlockValidationError>
pub fn verify(&self) -> Result<(), BlockValidationError>
Returns Ok if and only if the block’s provided block hash and body hash are identical to
those generated by hashing the appropriate input data.
Sourcepub fn random_with_specifics<I: IntoIterator<Item = DeployHash>>(
rng: &mut TestRng,
era_id: EraId,
height: u64,
protocol_version: ProtocolVersion,
is_switch: bool,
deploy_hashes_iter: I,
) -> Self
Available on crate features std and testing only.
pub fn random_with_specifics<I: IntoIterator<Item = DeployHash>>( rng: &mut TestRng, era_id: EraId, height: u64, protocol_version: ProtocolVersion, is_switch: bool, deploy_hashes_iter: I, ) -> Self
std and testing only.Returns a random block, but using the provided values.
If deploy_hashes_iter is empty, a few random deploy hashes will be added to the
deploy_hashes and transfer_hashes fields of the body. Otherwise, the provided deploy
hashes will populate the deploy_hashes field and transfer_hashes will be empty.
Trait Implementations§
Source§impl DataSize for BlockV1
impl DataSize for BlockV1
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§impl<'de> Deserialize<'de> for BlockV1
impl<'de> Deserialize<'de> for BlockV1
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for BlockV1
impl JsonSchema for BlockV1
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl ToBytes for BlockV1
impl ToBytes for BlockV1
Source§fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>
fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>
&self into a mutable writer.Source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Vec<u8> which would be returned from a successful call to
to_bytes() or into_bytes(). The data is not actually serialized, so this call is
relatively cheap.impl Eq for BlockV1
impl StructuralPartialEq for BlockV1
Auto Trait Implementations§
impl !Freeze for BlockV1
impl RefUnwindSafe for BlockV1
impl Send for BlockV1
impl Sync for BlockV1
impl Unpin for BlockV1
impl UnwindSafe for BlockV1
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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