Efficient Data Indexing for TON Blockchain with C++ Worker


The C++ worker for the TON indexer represents a critical component in the architecture of the TON (The Open Network) blockchain data management system. Designed to read data directly from TON node files, parse TL-B schemas, and efficiently insert the data into a PostgreSQL database, this worker enhances the performance and reliability of data indexing on the TON blockchain. This document provides a comprehensive guide on installing and configuring the C++ worker for optimal operation.

Installation Overview

The C++ worker can be set up in two distinct ways: as a systemd daemon for continuous operation or manually for more controlled deployment. Regardless of the method chosen, it is imperative to ensure that the TON Index database is properly configured prior to initiating the worker setup.

Installation Methods

1. Setup as Systemd Daemon

This method facilitates the worker’s operation as a background service, ensuring it runs continuously and restarts automatically upon failure or system reboot.

  • Command: ./scripts/add2systemd.sh <args> [--force]
  • Note: Utilize --force to rebuild the binary, if necessary.

2. Manual Installation

Manual installation offers more granular control over the build and execution process, ideal for development or testing environments.

  1. Install Required Packages: Ensure all dependencies are installed.
  2. Build TON Index Worker Binary: Compile the worker using CMake and Ninja.
  3. Install Binary: Move the compiled binary to a system-accessible location.
  4. Adjust System Limits: Increase the limit for maximum opened files.
  5. Run TON Index Worker: Execute the worker with the necessary arguments.

Configuration and Arguments

To achieve optimal performance, the worker can be configured with several arguments that dictate its operation, including database connection details, indexing start point, and parallelization settings.

Argument Description
--db <path> Path to the TON node directory.
--host <ip> PostgreSQL server IP address.
--port <port> PostgreSQL server port.
--user <user> PostgreSQL username.
--password <password> PostgreSQL password.
--dbname <dbname> PostgreSQL database name.
--from <seqno> Masterchain sequence number to start indexing from.
--max-parallel-tasks Maximum number of parallel disk reading tasks.
--insert-batch-size Maximum number of masterchain sequences in one INSERT query.
--insert-parallel-actors Maximum number of concurrent INSERT queries.


The C++ worker for the TON indexer significantly enhances the efficiency and scalability of blockchain data indexing on the TON network. By following the detailed installation and configuration guidelines provided, users can ensure a seamless setup process and optimal operation of the worker, contributing to the robustness and reliability of the TON blockchain infrastructure.