block.rs

Overview

This file defines data structures and conversion logic related to blockchain blocks, specifically for archival and serialization purposes. It focuses on representing block metadata, references to external blocks, and the flow of values within blocks. The primary struct, ArchBlock, serves as a comprehensive container for block-related information, facilitating conversions from database rows and serialized block data formats. It integrates with blockchain-specific types and serialization utilities, enabling interoperability between the database layer and the internal representation of blocks.


Data Structures

ExtBlkRef

A struct representing an external block reference. This includes optional fields that identify a block's sequence number, logical time, and cryptographic hashes.


BlockValueFlow

Represents the flow of values (e.g., tokens or currency units) within a block, including creation, export, import, and fees.


ArchBlock

The central struct representing an archived blockchain block with extensive metadata fields.


Functions and Implementations

Conversion: impl From<&Row<'_>> for ArchBlock

Constructs an ArchBlock from a SQLite database row.


Conversion: impl From<BlockSerializationSetFH> for ArchBlock

Constructs an ArchBlock from a serialized block structure BlockSerializationSetFH.


Helper Functions

serialize_block_ref

Converts a blockchain external block reference type (tvm_block::blocks::ExtBlkRef) into the module's ExtBlkRef.

serialize_value_flow

Converts a blockchain internal ValueFlow type into the module's BlockValueFlow.


Testing

Module: tests


Interactions with Other Modules


Important Implementation Details


Diagram

classDiagram
class ExtBlkRef {
+seq_no: Option<i64>
+end_lt: Option<String>
+file_hash: Option<String>
+root_hash: Option<String>
}
class BlockValueFlow {
+created: Option<String>
+exported: Option<String>
+fees_collected: Option<String>
+fees_imported: Option<String>
+imported: Option<String>
+minted: Option<String>
+recovered: Option<String>
}
class ArchBlock {
+id: String
+status: u8
+seq_no: u32
+parent: String
+aggregated_signature: Option<Vec<u8>>
+signature_occurrences: Option<Vec<u8>>
+share_state_resource_address: Option<String>
+global_id: Option<i64>
+version: Option<i64>
+after_merge: Option<bool>
+before_split: Option<bool>
+after_split: Option<bool>
+want_merge: Option<bool>
+want_split: Option<bool>
+key_block: Option<bool>
+flags: Option<i64>
+shard: Option<String>
+workchain_id: Option<i64>
+gen_utime: Option<i64>
+gen_utime_ms_part: Option<i64>
+start_lt: Option<String>
+end_lt: Option<String>
+gen_validator_list_hash_short: Option<i64>
+gen_catchain_seqno: Option<i64>
+min_ref_mc_seqno: Option<i64>
+prev_key_block_seqno: Option<i64>
+gen_software_version: Option<i64>
+gen_software_capabilities: Option<String>
+boc: Option<Vec<u8>>
+file_hash: Option<String>
+root_hash: Option<String>
+prev_ref: Option<ExtBlkRef>
+prev_alt_ref: Option<ExtBlkRef>
+in_msgs: Option<String>
+out_msgs: Option<String>
+data: Option<Vec<u8>>
+chain_order: Option<String>
+tr_count: Option<i64>
+value_flow: Option<BlockValueFlow>
+thread_id: Option<String>
+producer_id: Option<String>
}
ArchBlock o-- ExtBlkRef : "prev_ref, prev_alt_ref"
ArchBlock o-- BlockValueFlow : "value_flow"