[−][src]Struct exonum::blockchain::Block
Header of a block.
A block is essentially a list of transactions. Blocks are produced as a result of the consensus algorithm (thus authenticated by the supermajority of validators) and are applied atomically to the blockchain state. The header contains a block summary, such as the number of transactions and the transactions root hash, but not the transactions themselves.
Note that this structure is export-only, meaning that one can rely on the serialization format
provided by corresponding Protobuf definitions, but cannot expect Exonum nodes
or the exonum
crate to accept and process Block
s created externally.
Fields
height: Height
Height of the block, which is also the number of this particular block in the blockchain.
tx_count: u32
Number of transactions in this block.
prev_hash: Hash
Hash link to the previous block in the blockchain.
tx_hash: Hash
Root hash of the Merkle tree of transactions in this block.
state_hash: Hash
Hash of the blockchain state after applying transactions in the block.
error_hash: Hash
Root hash of the Merkle Patricia tree of the erroneous calls performed within the block.
These calls can include transactions, before_transactions
and/or after_transactions
hooks
for services.
additional_headers: AdditionalHeaders
Additional information that can be added into the block.
Methods
impl Block
[src]
pub fn epoch(&self) -> Option<Height>
[src]
Retrieves the epoch associated with this block, or None
if the epoch is not recorded.
pub fn is_skip(&self) -> bool
[src]
Checks if this block is formed as a result of skipping ordinary block creation.
pub fn get_header<K: BlockHeaderKey>(&self) -> Result<Option<K::Value>>
[src]
Gets the value of an additional header for the specified key type, which is specified via the type parameter.
Examples
// Suppose we store a list of active service IDs in a block. // We can do this by defining a corresponding BlockHeaderKey implementation. struct ActiveServices { service_ids: Vec<u32>, } // To implement `BlockHeaderKey` we need to provide the key name and a corresponding // value type. In this case it's `Self`. impl BlockHeaderKey for ActiveServices { const NAME: &'static str = "active_services"; type Value = Self; } // Create an empty block. let block = Block { // other fields skipped... additional_headers: AdditionalHeaders::new(), }; let services = block.get_header::<ActiveServices>().unwrap(); assert!(services.is_none());
Trait Implementations
impl BinaryValue for Block
[src]
fn to_bytes(&self) -> Vec<u8>
[src]
fn from_bytes(value: Cow<[u8]>) -> Result<Self, Error>
[src]
fn into_bytes(self) -> Vec<u8>
[src]
impl Clone for Block
[src]
impl Debug for Block
[src]
impl<'de> Deserialize<'de> for Block
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for Block
[src]
impl ObjectHash for Block
[src]
fn object_hash(&self) -> Hash
[src]
impl Ord for Block
[src]
fn cmp(&self, other: &Block) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Block> for Block
[src]
impl PartialOrd<Block> for Block
[src]
fn partial_cmp(&self, other: &Block) -> Option<Ordering>
[src]
fn lt(&self, other: &Block) -> bool
[src]
fn le(&self, other: &Block) -> bool
[src]
fn gt(&self, other: &Block) -> bool
[src]
fn ge(&self, other: &Block) -> bool
[src]
impl ProtobufConvert for Block
[src]
type ProtoStruct = Block
Type generated from the Protobuf definition.
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
[src]
fn to_pb(&self) -> Self::ProtoStruct
[src]
impl Serialize for Block
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for Block
[src]
impl StructuralPartialEq for Block
[src]
Auto Trait Implementations
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,