config.json
Overview
The `config.json` file serves as the primary configuration source for the application’s blockchain interaction and fiat currency rate fetching components. It defines essential parameters such as fiat currency rate providers, blockchain RPC connection details, mempool processing settings, coin-specific metadata, and operational timeouts. This JSON configuration allows the application to dynamically adjust its behavior without changing the codebase, supporting multiple fiat currencies, different coins (specifically Arbitrum in this case), and flexible mempool transaction management.
Detailed Explanation of Configuration Properties
1. fiat_rates
Type:
stringDescription: Specifies the source service for obtaining fiat currency exchange rates.
Example: "coingecko"
Usage: The application uses this value to determine which external API or service to query for fiat currency exchange rates.
2. fiat_rates_params
Type:
string(JSON serialized object)Description: Contains parameters required to connect to the fiat rate service. This is stored as a JSON-encoded string and should be parsed before use.
Contents:
url: Base URL for the API endpoint (e.g.,https://api.coingecko.com/api/v3)coin: The cryptocurrency to fetch rates for (e.g.,ethereum)platformIdentifier: Identifier for the blockchain platform (e.g.,ethereum)platformVsCurrency: Currency symbol against which rates are compared (e.g.,eth)periodSeconds: Refresh interval in seconds (e.g., 900 seconds = 15 minutes)
Usage: The application parses this string into a JSON object to configure API calls for fiat exchange rates.
3. fiat_rates_vs_currencies
Type:
string(comma-separated list)Description: List of fiat and cryptocurrency currencies against which exchange rates should be fetched.
Example:
"AED,ARS,AUD,BDT,...,BTC,ETH"Usage: Used to query exchange rates for the specified currencies from the fiat rate provider.
4. mempoolTxTimeoutHours
Type:
numberDescription: Number of hours after which unconfirmed transactions in the mempool are considered stale and discarded.
Example:
24Usage: Controls mempool cleanup to avoid processing indefinitely stuck transactions.
5. queryBackendOnMempoolResync
Type:
booleanDescription: Flag indicating whether to query the backend system when mempool resynchronization occurs.
Example:
falseUsage: If
true, the system triggers backend queries during mempool resyncs, possibly causing additional network or CPU load.
6. coin_name
Type:
stringDescription: Full name of the blockchain or coin supported by the system.
Example: "Arbitrum"
Usage: Used for UI display, logs, and internal referencing.
7. coin_shortcut
Type:
stringDescription: Short ticker symbol or abbreviation of the coin.
Example:
"ETH"Usage: Used in displays, transactions, and API calls.
8. coin_label
Type:
stringDescription: User-friendly label or marketing name of the coin or network.
Example: "Arbitrum Nova"
Usage: Displayed in UI components or reports.
9. rpc_url
Type:
stringDescription: WebSocket URL for connecting to the blockchain node RPC server.
Example:
"ws://localhost:8548"Usage: Used by the application to send RPC calls for blockchain data and transaction processing.
10. rpc_user
Type:
stringDescription: Username for RPC authentication (if required). Empty if no authentication.
Example:
""Usage: Credentials for RPC connection (optional).
11. rpc_pass
Type:
stringDescription: Password for RPC authentication (if required). Empty if no authentication.
Example:
""Usage: Credentials for RPC connection (optional).
12. rpc_timeout
Type:
numberDescription: Timeout in seconds for RPC calls to the blockchain node.
Example:
25Usage: Prevents hanging calls by limiting wait time for responses.
13. parse
Type:
booleanDescription: Flag indicating whether incoming transactions and blocks should be parsed or processed.
Example:
trueUsage: If
false, the application may skip parsing for faster operation or debugging.
14. message_queue_binding
Type:
stringDescription: Identifier or binding key for message queue integration (e.g., RabbitMQ or Kafka). Empty if no binding.
Example:
""Usage: Used for event-driven communication with other system components.
15. subversion
Type:
stringDescription: Version string or identifier for the blockchain node or client. Empty if unspecified.
Example:
""Usage: Used for compatibility checks or logging.
16. address_format
Type:
stringDescription: Format string or identifier for blockchain address formatting. Empty if default.
Example:
""Usage: May influence how addresses are displayed or validated.
17. mempool_workers
Type:
numberDescription: Number of concurrent worker threads or processes handling mempool transactions at the top level.
Example:
8Usage: Influences parallelism and throughput in mempool processing.
18. mempool_sub_workers
Type:
numberDescription: Number of sub-worker threads or processes for finer-grained mempool transaction processing.
Example:
2Usage: Provides additional concurrency within mempool workers.
19. block_addresses_to_keep
Type:
numberDescription: Number of block-associated addresses to retain in memory or cache for quick access.
Example:
300Usage: Balances memory usage against lookup performance for addresses linked to blocks.
Important Implementation Details
JSON Serialization for Parameters:
The propertyfiat_rates_paramsis stored as a serialized JSON string. The system must deserialize it before extracting individual parameters to configure API requests properly.Mempool Processing:
The configuration provides concurrency settings (mempool_workersandmempool_sub_workers) to optimize mempool transaction processing, likely using worker pools or thread pools. This design helps handle high transaction throughput efficiently.RPC Connection Management:
The application connects to a blockchain node via a WebSocket RPC URL with optional authentication and a timeout to ensure robust node communication.Fiat Rate Updates:
The periodic refresh of fiat rates is controlled by theperiodSecondsparameter withinfiat_rates_params, enabling the system to maintain up-to-date currency conversion data.
Interaction with Other System Components
Fiat Rate Provider Module:
Usesfiat_rates,fiat_rates_params, andfiat_rates_vs_currenciesto fetch and cache exchange rates for various currencies, which can be used for pricing, reporting, or UI display.Blockchain Node Interface:
Connects to the blockchain node using therpc_urland related credentials to submit transactions, query blockchain state, and listen for events.Mempool Manager:
Utilizes mempool configuration parameters to manage unconfirmed transactions, including worker pools and timeout policies.Message Queue System:
If enabled (message_queue_bindingis set), integrates with messaging infrastructure to communicate events or data between microservices or backend components.UI and Reporting Layers:
Display coin-related labels (coin_name,coin_label,coin_shortcut) and currency rates, enhancing user experience with accurate and localized information.
Usage Example
Suppose the application wants to fetch the fiat exchange rates from CoinGecko every 15 minutes for Ethereum against USD and other currencies:
Parse
fiat_rates_paramsJSON string to extract URL and coin info.Use
fiat_rates_vs_currenciesto specify the target currencies for the exchange rates.Fetch data from CoinGecko API endpoint
https://api.coingecko.com/api/v3.Cache and refresh the data every 900 seconds (15 minutes).
Use
rpc_urland credentials to connect to the Arbitrum blockchain for transaction processing.Use mempool worker settings to handle incoming transactions efficiently.
Mermaid Diagram: Configuration Structure Flowchart
This flowchart illustrates the main configuration categories and their relationships in `config.json`.
flowchart TD
A[config.json]
A --> B[Fiat Rate Settings]
B --> B1[fiat_rates]
B --> B2[fiat_rates_params (JSON string)]
B --> B3[fiat_rates_vs_currencies]
A --> C[Blockchain Node Settings]
C --> C1[rpc_url]
C --> C2[rpc_user]
C --> C3[rpc_pass]
C --> C4[rpc_timeout]
C --> C5[subversion]
C --> C6[address_format]
A --> D[Mempool Settings]
D --> D1[mempoolTxTimeoutHours]
D --> D2[queryBackendOnMempoolResync]
D --> D3[mempool_workers]
D --> D4[mempool_sub_workers]
D --> D5[block_addresses_to_keep]
A --> E[Coin Info]
E --> E1[coin_name]
E --> E2[coin_shortcut]
E --> E3[coin_label]
A --> F[Miscellaneous]
F --> F1[parse]
F --> F2[message_queue_binding]
Summary
The `config.json` file is a centralized configuration resource that controls the behavior of the fiat currency rate fetching, blockchain RPC communication, mempool processing, and coin metadata for the application. It enables flexible, scalable, and maintainable operation by externalizing key parameters into a single JSON structure. Proper parsing and handling of this configuration ensure efficient integration with external APIs and blockchain nodes, as well as optimized transaction processing workflows.