config.json
Overview
The `config.json` file serves as a configuration blueprint for the Blockbook Indexer Service tailored to the **BNB Smart Chain** blockchain within the Multi-Blockchain Coinstacks architecture. This JSON file encapsulates essential parameters that dictate how the indexer connects to blockchain nodes, processes mempool transactions, manages caching, and integrates external fiat currency rates for enriching blockchain data.
By externalizing these settings, the indexer achieves flexibility and adaptability to different blockchain environments without code changes. It enables fine-tuning of performance characteristics (e.g., concurrency levels), external API integration (e.g., CoinGecko fiat rates), and blockchain-specific details (e.g., coin name, RPC endpoints).
Configuration Parameters Detailed Explanation
Key | Type | Description | Example / Default Value |
|---|---|---|---|
`fiat_rates_vs_currencies` | String | Comma-separated list of fiat and crypto currency codes to fetch exchange rates against the blockchain coin. | `"AED,ARS,AUD,BDT,BHD,...,USD,BTC,ETH"` |
`fiat_rates_params` | String | JSON string specifying parameters for the fiat rates API request. Includes URL, coin identifier, platform currency, and update period in seconds. | |
`mempoolTxTimeoutHours` | Integer | Number of hours after which unconfirmed mempool transactions are considered stale and discarded. | `24` |
`queryBackendOnMempoolResync` | Boolean | Whether to query the backend blockchain node again when resynchronizing mempool transactions. | `false` |
`coin_name` | String | Full human-readable name of the blockchain coin. | `"BNB Smart Chain"` |
`coin_shortcut` | String | Short ticker symbol or shortcut for the coin. | `"BNB"` |
`coin_label` | String | Label used for display or logging purposes. | `"BNB Smart Chain"` |
`rpc_url` | String | WebSocket URL of the blockchain RPC node for JSON-RPC communications. | `"ws://localhost:8546"` |
`rpc_user` | String | Username for RPC authentication, if applicable. | `""` (empty if no auth) |
`rpc_pass` | String | Password for RPC authentication, if applicable. | `""` (empty if no auth) |
`rpc_timeout` | Integer | Timeout in seconds for RPC calls before considering them failed. | `25` |
`parse` | Boolean | Flag indicating whether to parse blockchain data in detail. | `true` |
`message_queue_binding` | String | Name or identifier for message queue binding if used for synchronization or notification. | `""` (empty if not configured) |
`subversion` | String | Optional subversion string for client identification or logging. | `""` (empty if not specified) |
`address_format` | String | Address format type or encoding used by this blockchain (e.g., bech32, base58). | `""` (empty if default or unspecified) |
`mempool_workers` | Integer | Number of concurrent worker threads/processes dedicated to processing mempool transactions. | `8` |
`mempool_sub_workers` | Integer | Number of sub-workers per mempool worker to further parallelize processing. | `2` |
`block_addresses_to_keep` | Integer | Number of recent blocks for which address data is cached and retained in memory. | `300` |
Usage and Examples
Typical Usage
The `config.json` file is loaded at the startup of the Blockbook Indexer service instance for BNB Smart Chain. The indexer reads these parameters to:
Connect to the BNB Smart Chain node via the configured WebSocket RPC URL.
Authenticate RPC calls if credentials are provided.
Configure concurrency for mempool transaction processing to optimize throughput.
Define caching policies for block addresses.
Schedule periodic queries to CoinGecko API for fiat exchange rates using the specified parameters.
Manage mempool transaction lifetimes and resynchronization behavior.
Format addresses and parse blockchain data accordingly.
The configuration ensures the indexer behaves as expected for this specific blockchain environment.
Important Implementation Details
Fiat Rates Integration:
Thefiat_rates_paramsstring contains a JSON-encoded object describing the CoinGecko API endpoint and parameters. The indexer periodically fetches exchange rates for the specifiedfiat_rates_vs_currenciesagainst the blockchain coin (binancecoinin this case). The data refresh interval is controlled byperiodSeconds(900 seconds = 15 minutes).Mempool Concurrency:
Themempool_workersandmempool_sub_workersparameters allow the indexer to parallelize mempool transaction processing with a two-level worker pool. This improves performance especially under heavy transaction load.RPC Connection:
The indexer uses a WebSocket URL (ws://localhost:8546) to maintain persistent RPC connections for real-time blockchain data. Timeout and authentication parameters ensure robust communication.Caching Policy:
Retaining address data for the last 300 blocks (block_addresses_to_keep) helps optimize queries related to recent blockchain activity without excessive memory use.Data Parsing:
Theparseflag beingtrueindicates that the indexer will perform detailed parsing of blockchain data (transactions, addresses) instead of treating data opaquely.
Interaction with Other Components
Daemon Nodes:
Therpc_url,rpc_user, andrpc_passparameters connect the indexer to the blockchain daemon node. The daemon node provides blockchain data, which the indexer processes and caches.API Server:
The indexer exposes parsed blockchain data and mempool state to the API server, which serves client queries.Message Queues:
If configured, themessage_queue_bindingallows the indexer to receive or send blockchain event notifications for synchronization purposes.Fiat Rate Providers:
The indexer regularly fetches fiat exchange rates from CoinGecko using the parameters specified in the config.
Visual Diagram
The following **flowchart** presents the role of this configuration file in the overall workflow of the Blockbook Indexer service:
flowchart TD
Config[config.json] -->|Loads RPC & concurrency settings| Indexer[Blockbook Indexer Service]
Config -->|Defines fiat rate API params| FiatAPI[Fiat Rate Fetcher]
Config -->|Sets mempool processing parameters| Mempool[Mempool Processing Workers]
Indexer -->|Connects via RPC| Daemon[Daemon Node (Blockchain)]
Indexer -->|Exposes data| API[API Server]
FiatAPI -->|Fetches rates| CoinGecko[CoinGecko API]
Mempool -->|Processes transactions| Indexer
Summary
config.jsonis a critical configuration file for the Blockbook Indexer tailored to BNB Smart Chain.It specifies connection details to the blockchain node, concurrency for mempool processing, caching policies, and fiat rate integration parameters.
The file enables the indexer to be flexible and configurable without code changes.
It interacts closely with daemon nodes for data, API servers for serving requests, and external fiat rate providers for currency conversion data.
Proper configuration here ensures efficient, scalable, and accurate blockchain indexing and data service.
Appendix: Example snippet from config.json
{
"fiat_rates_vs_currencies": "AED,ARS,AUD,BDT,BHD,BMD,BRL,CAD,CHF,CLP,CNY,CZK,DKK,EUR,GBP,HKD,HUF,IDR,ILS,INR,JPY,KRW,KWD,LKR,MMK,MXN,MYR,NGN,NOK,NZD,PHP,PKR,PLN,RUB,SAR,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,VND,ZAR,BTC,ETH",
"fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"binancecoin\",\"platformIdentifier\": \"binance-smart-chain\",\"platformVsCurrency\": \"bnb\",\"periodSeconds\": 900}",
"mempoolTxTimeoutHours": 24,
"queryBackendOnMempoolResync": false,
"coin_name": "BNB Smart Chain",
"coin_shortcut": "BNB",
"coin_label": "BNB Smart Chain",
"rpc_url": "ws://localhost:8546",
"rpc_user": "",
"rpc_pass": "",
"rpc_timeout": 25,
"parse": true,
"message_queue_binding": "",
"subversion": "",
"address_format": "",
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 300
}
This completes the comprehensive documentation for the `config.json` file.