toncenter / ton-index-worker

9 stars 5 forks source link

TON Index (C++ Worker)

This is a C++ worker for TON indexer. This worker reads data from TON node files, parses TL-B schemas, and inserts data into PostgreSQL database.

1. How to install

Before installing the worker, ensure the TON Index database is set up using the instructions provided.

1.1. Setup as systemd daemon

To install as a daemon use the script below:

./scripts/add2systemd.sh --db /var/ton-work/db --host <ip> --port <port> \
                         --user <postgres user> --password <postgres password> --dbname <database name> \
                         --from 1 --max-active-tasks $(nproc) --threads $(nproc) \
                         --max-insert-actors <number of insert actors> [--force]

You may find the list of arguments in section available arguments. Use flag --force to force rebuild binary.

NOTE: We strongly recommend to setup worker separately from the database server because of significant RAM and Disk IO usage.

1.2. Manual install

Do the following steps to build and run index worker from source.

  1. Install required packages:

    sudo apt-get update -y
    sudo apt-get install -y build-essential cmake clang openssl libssl-dev zlib1g-dev gperf wget git curl libreadline-dev ccache libmicrohttpd-dev pkg-config libsecp256k1-dev libsodium-dev python3-dev libpq-dev ninja-build
  2. Build TON index worker binary:

    mkdir -p build
    cd build
    cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=off -GNinja ..
    ninja -j$(nproc) ton-index-postgres
  3. Install binary to your system:

    sudo cmake --install 
  4. Increase maximum opened files limit:

    ulimit -n 1000000
  5. Run TON index worker:

    ton-index-postgres <args>

1.3. Available arguments: