config.json
Overview
`config.json` is a configuration file used by the Blockbook Indexer Service for the Bitcoin Cash (BCH) blockchain network. It defines essential parameters that govern how the indexer connects to the blockchain node, manages data indexing, processes mempool transactions, formats addresses, and integrates external services such as fiat currency rate providers.
The file’s primary role is to supply the indexer with blockchain-specific settings, RPC connection details, concurrency options, and fiat rate update configurations. This enables the Blockbook indexer to efficiently track blockchain state changes, cache relevant data, and enrich blockchain data with up-to-date fiat currency values.
Configuration Properties and Their Descriptions
Property | Type | Description | Example Value |
|---|---|---|---|
`fiat_rates` | string | Specifies the external fiat currency rate provider used to fetch exchange rates for the cryptocurrency. | `"coingecko"` |
`fiat_rates_params` | string | JSON string containing parameters specific to the fiat rate provider, such as API URL, coin id, and refresh period in seconds. | `"{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"bitcoin-cash\", \"periodSeconds\": 900}"` |
`fiat_rates_vs_currencies` | string | Comma-separated list of fiat and crypto currency codes against which the coin’s rates are fetched. | `"AED,ARS,AUD,...,USD,BTC,ETH"` |
`coin_name` | string | Human-readable short name of the coin used internally within the indexer. | `"Bcash"` |
`coin_shortcut` | string | Short ticker symbol of the coin. | `"BCH"` |
`coin_label` | string | Full display label of the coin. | `"Bitcoin Cash"` |
`rpc_url` | string | URL of the blockchain RPC node to which the indexer connects for blockchain data access. | `"http://localhost:8332"` |
`rpc_user` | string | Username for RPC node authentication. | `"user"` |
`rpc_pass` | string | Password for RPC node authentication. | `"password"` |
`rpc_timeout` | number | Timeout in seconds for RPC requests to the blockchain node. | `25` |
`parse` | boolean | Flag indicating whether to parse transactions and blocks for indexing. | `true` |
`message_queue_binding` | string | Endpoint URL for the message queue used to synchronize blockchain events or distribute workload among indexer instances. | `"tcp://localhost:28332"` |
`subversion` | string | Optional version string identifying the subversion of the blockchain node or indexer. | `""` (empty string in this config) |
`address_format` | string | The address format used by the blockchain (e.g., `cashaddr` for Bitcoin Cash). | `"cashaddr"` |
`xpub_magic` | number | Magic number for extended public keys used in HD wallets specific to the blockchain. | `76067358` |
`slip44` | number | SLIP-0044 coin type number identifying the blockchain in HD wallets and related libraries. | `145` |
`mempool_workers` | number | Number of worker threads for processing mempool (unconfirmed) transactions concurrently. | `8` |
`mempool_sub_workers` | number | Number of sub-worker threads per mempool worker to further parallelize mempool transaction processing. | `2` |
`block_addresses_to_keep` | number | Number of recent blocks' worth of addresses to retain in memory/cache for efficient address lookups. | `300` |
Detailed Explanation of Key Parameters
Fiat Rate Integration Parameters
fiat_rates: Indicates which external service to use for fetching fiat exchange rates."coingecko"is a popular cryptocurrency data provider.fiat_rates_params: Contains a JSON string with:url: The base API URL of the fiat rate provider.coin: Coin identifier used in the provider’s API (here"bitcoin-cash").periodSeconds: Interval at which to refresh fiat rate data (900 seconds = 15 minutes).
fiat_rates_vs_currencies: Defines the fiat and crypto currencies against which to fetch exchange rates. This list includes global currencies like USD, EUR, INR, and cryptocurrencies like BTC and ETH.
Usage Example:
{
"fiat_rates": "coingecko",
"fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"bitcoin-cash\", \"periodSeconds\": 900}",
"fiat_rates_vs_currencies": "USD,EUR,BTC,ETH"
}
The indexer uses these parameters to periodically send requests to CoinGecko’s API, retrieve up-to-date price data for Bitcoin Cash against the listed currencies, and store this data to enrich client responses.
RPC Node Connection
rpc_url,rpc_user,rpc_pass,rpc_timeout: These parameters configure the JSON-RPC connection to the Bitcoin Cash node. The indexer uses RPC calls to fetch blockchain data like blocks, transactions, and mempool state.
Example:
{
"rpc_url": "http://localhost:8332",
"rpc_user": "user",
"rpc_pass": "password",
"rpc_timeout": 25
}
The indexer authenticates with the node and performs calls within the timeout window to ensure responsiveness.
Blockchain Identification and Addressing
coin_name,coin_shortcut,coin_label: Provide human-readable and symbolic identifiers for the blockchain.address_format: Defines how addresses are encoded. Bitcoin Cash uses the"cashaddr"format to avoid confusion with Bitcoin addresses.xpub_magic: Magic prefix for extended public keys (used in hierarchical deterministic wallets).slip44: The registered coin type for Bitcoin Cash (145) from the SLIP-0044 standard.
These parameters ensure the indexer correctly interprets blockchain data and formats addresses and keys in a consistent manner.
Mempool Processing
mempool_workersandmempool_sub_workers: Control concurrency levels for processing unconfirmed transactions in the mempool. Higher values improve throughput in high-transaction environments but consume more system resources.block_addresses_to_keep: Specifies how many recent blocks’ worth of addresses should be cached in-memory for quick lookup, balancing memory usage and query performance.
Miscellaneous
parse: When true, the indexer parses transactions and blocks for indexing. Disabling parsing might be used for debugging or minimal indexing.message_queue_binding: Defines the address of the message queue for real-time blockchain event handling or distributing indexing tasks. Typically a TCP endpoint.subversion: Optional versioning string; left empty in this configuration.
Usage Example in Context
Suppose you want to run the Blockbook indexer for Bitcoin Cash using this configuration. The indexer will:
Connect to the Bitcoin Cash full node at
http://localhost:8332with the provided user credentials.Parse incoming blocks and transactions, processing them with up to 8 mempool worker threads and 2 sub-workers each.
Cache addresses from the last 300 blocks for fast lookup.
Format addresses in
cashaddrformat, using the SLIP44 coin type145.Periodically query CoinGecko every 15 minutes for Bitcoin Cash exchange rates against a wide range of fiat and crypto currencies.
Bind to the message queue at
tcp://localhost:28332to receive blockchain event notifications or to share workload.
Implementation Details and Algorithms
Fiat Rate Fetching: The indexer parses the
fiat_rates_paramsJSON string to configure API calls to CoinGecko. It polls the API at intervals defined byperiodSeconds, updating cached fiat rates used to convert BCH balances to fiat and other cryptocurrencies.Mempool Concurrency: The
mempool_workersandmempool_sub_workersparameters are used to create thread pools or async workers that concurrently process mempool transactions, improving indexing speed.Address Caching: The indexer maintains an in-memory cache of addresses seen in the last
block_addresses_to_keepblocks, enabling rapid address lookups without repeated disk or database queries.RPC Communication: JSON-RPC calls use the provided credentials and timeout to communicate with the BCH node, fetching block and transaction data reliably.
Message Queue Integration: The configured
message_queue_bindingendpoint allows the indexer to subscribe to real-time blockchain events or distribute indexing tasks in a scalable environment.
Interaction with Other Components
Daemon Nodes: The indexer connects to the Bitcoin Cash daemon node via RPC to receive raw blockchain data. The daemon is authoritative for blockchain state.
API Servers: The indexer serves enriched blockchain data (including fiat conversions) to API servers through RESTful and WebSocket interfaces (configured elsewhere).
Message Queue: The indexer uses the message queue endpoint to synchronize with other indexer instances or receive blockchain event notifications, enabling horizontal scaling and real-time updates.
Wallets/Clients: By adhering to standards like SLIP44 and address formats like
cashaddr, the indexer ensures compatibility with wallets and client applications that rely on consistent blockchain data.
Visual Diagram: Flowchart of Configuration Role in Indexer Workflow
flowchart TD
Config[config.json]
RPC[Blockchain RPC Node]
MQ[Message Queue]
Indexer[Blockbook Indexer Service]
FiatAPI[Fiat Rate Provider API]
Cache[Address & Fiat Rate Cache]
Workers[Mempool Workers]
Config -->|RPC params| RPC
Config -->|MQ endpoint| MQ
Config -->|Fiat rate params| FiatAPI
Config -->|Concurrency settings| Workers
Indexer -->|Fetch blockchain data| RPC
Indexer -->|Subscribe events| MQ
Indexer -->|Fetch fiat rates| FiatAPI
Indexer -->|Cache data| Cache
Workers -->|Process mempool txs| Indexer
**Diagram Explanation:** This flowchart shows how the `config.json` file provides key parameters to the Blockbook Indexer Service. The indexer uses RPC details to fetch blockchain data, connects to a message queue for event-driven updates, polls an external fiat rate API, and manages concurrency through worker threads. All processed and enriched data is cached for fast access by API servers and clients.
Summary
The `config.json` file is a critical piece of the Blockbook Indexer’s deployment, encapsulating all necessary parameters for:
Connecting securely to the Bitcoin Cash node via RPC.
Configuring concurrency and caching policies for efficient data processing.
Defining blockchain-specific identifiers and address formats.
Integrating fiat currency rate providers for enhanced data enrichment.
Managing real-time synchronization via message queue endpoints.
By properly setting these parameters, the indexer can deliver performant, accurate, and enriched blockchain data to the broader Multi-Blockchain Coinstacks ecosystem, supporting wallet services, analytics, and client applications.