mod.rs

Overview

This file defines the GraphQL schema entities and data transformation logic related to blockchain blocks within the system. It provides detailed data structures representing blocks, their references, value flows, transactions, and statuses, along with the necessary conversions from database models to GraphQL objects. The file primarily facilitates querying block-related data in a structured manner via GraphQL, including complex field formatting and relationships between blocks and their messages.

The file also exposes filtering and resolver modules (filter and resolver) for block-related queries, enabling flexible data access and manipulation.

Modules and Re-exports

Type Aliases

These aliases improve readability for GraphQL type mapping.

Enum: BlockProcessingStatusEnum

Represents the processing status of a block.

Variants

Implementation Details

Usage Example

let status_enum = BlockProcessingStatusEnum::from(Some(2)); // returns Finalized

Struct: ExtBlkRef

Represents an external block reference with optional fields.

Fields

Complex Fields and Methods

Usage

Used to represent references to other blocks, such as previous blocks or alternative references.

Structs: BlockMasterShardHashesDescr, BlockMasterShardHashes, BlockMaster

These represent nested structures related to masterchain shard hashes, including generation time and root hash.

Used internally within the Block struct to describe masterchain block details.

Struct: Directives

Contains directive-related information for a block.

Struct: BlockValueFlow

Represents the flow of value (currency) within a block.

Fields

ComplexObject Methods

Each numeric string field has an async method that formats the amount using format_big_int for presentation.

Usage

Used to track currency movements such as minted tokens, fees, and transfers related to a block.

Struct: BlockAccountBlocksTransactions

Represents individual transactions within account blocks of a block.

Fields

ComplexObject Methods

Struct: BlockAccountBlocks

Represents account blocks within a block.

Fields

Struct: Block

Core GraphQL object representing a blockchain block with extensive fields.

Selected Fields

Conversion from Database Model

Implements From<db::Block> trait to convert from database block representation to GraphQL Block. This involves:

ComplexObject Methods

Other Methods

Interaction with Other Parts of the System

Important Implementation Details


Mermaid Diagram: Structure of mod.rs

classDiagram
class Block {
+id: String
+account_blocks: Option<Vec<BlockAccountBlocks>>
+after_merge: Option<Boolean>
+after_split: Option<Boolean>
+aggregated_signature: Vec<u8>
+before_split: Option<Boolean>
+boc: Option<String>
+chain_order: Option<String>
+created_by: Option<String>
+directives: Directives
+file_hash: String
+flags: Option<Int>
+gen_catchain_seqno: Option<Float>
+gen_software_capabilities: Option<String>
+gen_software_version: Option<Float>
+gen_utime: Option<Int>
+gen_utime_string: String
+global_id: Option<Int>
+hash: Option<String>
+in_msg_descr: Option<Vec<Option<InMsg>>>
+key_block: Option<Boolean>
+master: Option<BlockMaster>
+master_ref: Option<ExtBlkRef>
+prev_ref: Option<ExtBlkRef>
+prev_alt_ref: Option<ExtBlkRef>
+producer_id: Option<String>
+rand_seed: String
+seq_no: i64
+shard: Option<String>
+status: u8
+status_name: BlockProcessingStatusEnum
+thread_id: Option<String>
+tr_count: Option<i32>
+value_flow: Option<BlockValueFlow>
+version: Option<Float>
+workchain_id: Option<i64>
+set_in_msg_descr()
}
class ExtBlkRef {
-end_lt: Option<String>
+file_hash: Option<String>
+root_hash: Option<String>
+seq_no: Option<f64>
+end_lt()
}
class BlockValueFlow {
-created: Option<String>
+created_other: Option<Vec<OtherCurrency>>
-exported: Option<String>
+exported_other: Option<Vec<OtherCurrency>>
-fees_collected: Option<String>
+fees_collected_other: Option<Vec<OtherCurrency>>
-fees_imported: Option<String>
+fees_imported_other: Option<Vec<OtherCurrency>>
-from_prev_blk: Option<String>
+from_prev_blk_other: Option<Vec<OtherCurrency>>
-imported: Option<String>
+imported_other: Option<Vec<OtherCurrency>>
-minted: Option<String>
+minted_other: Option<Vec<OtherCurrency>>
-to_next_blk: Option<String>
+to_next_blk_other: Option<Vec<OtherCurrency>>
+created()
+exported()
+fees_collected()
+fees_imported()
+from_prev_blk()
+imported()
+minted()
+to_next_blk()
}
class BlockAccountBlocks {
+account_addr: Option<String>
+new_hash: Option<String>
+old_hash: Option<String>
+tr_count: Option<i32>
+transactions: Option<Vec<BlockAccountBlocksTransactions>>
}
class BlockAccountBlocksTransactions {
-lt: Option<String>
-total_fees: Option<String>
+total_fees_other: Option<Vec<OtherCurrency>>
+transaction_id: Option<String>
+lt()
+total_fees()
}
class BlockMaster {
+shard_hashes: Option<BlockMasterShardHashes>
}
class BlockMasterShardHashes {
+workchain_id: Option<Int>
+shard: Option<String>
+descr: Option<BlockMasterShardHashesDescr>
}
class BlockMasterShardHashesDescr {
+gen_utime: Option<f64>
+root_hash: Option<String>
}
class Directives {
+share_state_resource_address: Option<String>
}
Block --> ExtBlkRef : prev_ref, prev_alt_ref, master_ref
Block --> BlockValueFlow : value_flow
Block --> BlockAccountBlocks : account_blocks
BlockAccountBlocks --> BlockAccountBlocksTransactions : transactions
Block --> BlockMaster : master
BlockMaster --> BlockMasterShardHashes : shard_hashes
BlockMasterShardHashes --> BlockMasterShardHashesDescr : descr
Block --> Directives : directives

This diagram illustrates the primary data structures in the file and their relationships, showing how the Block object is composed of multiple nested entities representing block metadata, references, transaction details, and value flow.