blockchain_config.rs

Overview

The blockchain_config.rs file is responsible for loading and parsing the blockchain configuration from a JSON file into a structured format used by the system. It provides a mechanism to read the configuration parameters from a static JSON file embedded in the binary and convert them into a BlockchainConfig instance. This configuration is essential for initializing blockchain-related components of the system and ensuring they operate with the correct parameters.

Detailed Explanation

Constants

BLOCKCHAIN_CONFIG: &str

Functions

load_blockchain_config() -> anyhow::Result<BlockchainConfig>

match load_blockchain_config() {
    Ok(config) => {
        // Use the config for blockchain initialization
    },
    Err(e) => {
        eprintln!("Error loading blockchain config: {}", e);
    }
}

Implementation Details and Algorithms

Interaction with Other System Components

Mermaid Diagram

classDiagram
class blockchain_config {
<<module>>
+BLOCKCHAIN_CONFIG: &str
+load_blockchain_config() Result<BlockchainConfig>
}
class serde_json_Map {
<<type>>
}
class BlockchainConfig {
<<struct>>
+with_config()
}
class tvm_block_json {
<<module>>
+parse_config()
}
blockchain_config --> serde_json_Map : parses JSON
blockchain_config --> tvm_block_json : calls parse_config
blockchain_config --> BlockchainConfig : calls with_config

This diagram illustrates the main components and their interactions within blockchain_config.rs: the static JSON string, JSON map parsing, configuration parameter parsing, and constructing the final BlockchainConfig instance.