### Build and Install PGTON Extension Source: https://github.com/toncenter/ton-index-worker/blob/main/pgton/README.md This snippet outlines the necessary shell commands to build and install the PGTON PostgreSQL extension. It covers dependency installation, creating a build directory, configuring the build with CMake, compiling the extension, and installing the binaries. ```bash sudo apt update && sudo apt install postgresql-server-dev-all cmake mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release .. && make -j32 pgton cd pgton && sudo make install ``` -------------------------------- ### Run TON Index Worker (Shell) Source: https://github.com/toncenter/ton-index-worker/blob/main/README.md Executes the TON Index worker binary with specified arguments. The arguments configure database connection, indexing start point, and performance tuning parameters. ```Shell ton-index-postgres-v2 ``` -------------------------------- ### Install TON Index Worker Binary (Shell) Source: https://github.com/toncenter/ton-index-worker/blob/main/README.md Installs the compiled TON Index worker binary to the system's PATH after the build process. ```Shell sudo cmake --install ``` -------------------------------- ### Build ton-trace-task-emulator Executable (CMake) Source: https://github.com/toncenter/ton-index-worker/blob/main/ton-trace-task-emulator/CMakeLists.txt Configures the build process for the ton-trace-task-emulator executable using CMake. It lists source files, includes necessary directories, sets C++ standard to C++20, links required libraries (ton-trace-emulator-core, hiredis, redis++, msgpack-cxx), sets compile definitions, and defines runtime installation. ```cmake cmake_minimum_required(VERSION 3.16) add_executable(ton-trace-task-emulator src/main.cpp src/TraceTaskScheduler.cpp src/TaskResultInserter.cpp src/RedisListener.cpp ) target_include_directories(ton-trace-task-emulator PUBLIC ${CMAKE_BINARY_DIR}/external/redis-plus-plus/src ) target_compile_features(ton-trace-task-emulator PRIVATE cxx_std_20) target_link_libraries(ton-trace-task-emulator ton-trace-emulator-core hiredis redis++ msgpack-cxx) target_link_options(ton-trace-task-emulator PUBLIC -rdynamic) target_compile_definitions(ton-trace-task-emulator PRIVATE -DMSGPACK_USE_DEFINE_MAP) install(TARGETS ton-trace-task-emulator RUNTIME DESTINATION bin) ``` -------------------------------- ### Build TON Index Worker Binary (Shell) Source: https://github.com/toncenter/ton-index-worker/blob/main/README.md Compiles the TON Index worker using CMake and Ninja. This process generates the PostgreSQL v2 binary, optimized for release. ```Shell mkdir -p build cd build cmake -DCMAKE_BUILD_TYPE=Release -GNinja .. ninja -j$(nproc) ton-index-postgres-v2 ``` -------------------------------- ### Install TON Index Worker as Systemd Daemon (Shell) Source: https://github.com/toncenter/ton-index-worker/blob/main/README.md This script installs the TON Index worker as a systemd service, allowing it to run in the background. It requires specifying database connection details and indexing parameters. ```Shell ./scripts/add2systemd.sh --db /var/ton-work/db --host --port \ --user --password --dbname \ --from 1 --max-active-tasks $(nproc) --threads $(nproc) \ --max-insert-actors [--force] ``` -------------------------------- ### Install Required Packages for TON Index Worker (Shell) Source: https://github.com/toncenter/ton-index-worker/blob/main/README.md Installs necessary development packages for building the TON Index worker on a Debian-based system. This includes build tools, compilers, and libraries. ```Shell 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 ``` -------------------------------- ### Build TON Trace Emulator Executable (CMake) Source: https://github.com/toncenter/ton-index-worker/blob/main/ton-trace-emulator/CMakeLists.txt Configures the main executable 'ton-trace-emulator' for the TON Index Worker. It links the 'ton-trace-emulator-core' library and other dependencies like hiredis, redis++, and msgpack-cxx. It also sets C++20 standard, defines a message pack compilation flag, and installs the executable to the 'bin' directory. ```cmake add_executable(ton-trace-emulator src/main.cpp src/TraceScheduler.cpp src/TraceInserter.cpp src/RedisListener.cpp ) target_include_directories(ton-trace-emulator PUBLIC ${CMAKE_BINARY_DIR}/external/redis-plus-plus/src ) target_compile_features(ton-trace-emulator PRIVATE cxx_std_20) target_compile_definitions(ton-trace-emulator PRIVATE -DMSGPACK_USE_DEFINE_MAP) target_link_libraries(ton-trace-emulator ton-trace-emulator-core hiredis redis++ msgpack-cxx) target_link_options(ton-trace-emulator PUBLIC -rdynamic) install(TARGETS ton-trace-emulator RUNTIME DESTINATION bin) ``` -------------------------------- ### Increase Maximum Opened Files Limit (Shell) Source: https://github.com/toncenter/ton-index-worker/blob/main/README.md Sets a higher limit for the number of concurrently opened files for the current shell session, which is often necessary for high-performance applications like the TON Index worker. ```Shell ulimit -n 1000000 ``` -------------------------------- ### Configure ton-index-worker with CMake Source: https://github.com/toncenter/ton-index-worker/blob/main/CMakeLists.txt This CMakeLists.txt file sets up the build environment for the ton-index-worker project. It defines project name, build options like jemalloc and pgton support, manages module paths, finds required packages, and includes various subdirectories for different components and external dependencies. ```cmake cmake_minimum_required(VERSION 3.16) project(ton-index-cpp) option(PGTON "Enable adding the pgton subdirectory" OFF) option(TON_USE_JEMALLOC "Use \"ON\" to enable JeMalloc." OFF) # Find jemalloc if (TON_USE_JEMALLOC) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/ton/CMake") find_package(jemalloc REQUIRED) if (JEMALLOC_FOUND) include_directories(${JEMALLOC_INCLUDE_DIR}) link_libraries(${JEMALLOC_LIBRARIES}) add_compile_definitions(TON_USE_JEMALLOC) endif() endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) add_subdirectory(external/ton EXCLUDE_FROM_ALL) add_subdirectory(external/libpqxx EXCLUDE_FROM_ALL) add_subdirectory(external/clickhouse-cpp EXCLUDE_FROM_ALL) add_subdirectory(external/hiredis EXCLUDE_FROM_ALL) set(HIREDIS_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/external CACHE PATH "hiredis header" FORCE) set(HIREDIS_LIB hiredis CACHE STRING "hiredis lib" FORCE) set(REDIS_PLUS_PLUS_BUILD_TEST OFF CACHE BOOL "disable test" FORCE) add_subdirectory(external/redis-plus-plus EXCLUDE_FROM_ALL) set(MSGPACK_USE_BOOST OFF CACHE BOOL "disable boost" FORCE) set(MSGPACK_USE_STD_VARIANT_ADAPTOR ON CACHE BOOL "enable std::variant" FORCE) add_subdirectory(external/msgpack-c EXCLUDE_FROM_ALL) add_subdirectory(tondb-scanner) add_subdirectory(ton-index-postgres) add_subdirectory(ton-index-postgres-v2) add_subdirectory(ton-index-clickhouse) add_subdirectory(ton-integrity-checker) add_subdirectory(ton-smc-scanner) add_subdirectory(ton-trace-emulator) add_subdirectory(ton-trace-task-emulator) add_subdirectory(celldb-migrate) if (PGTON) message("Building pgton") add_subdirectory(pgton) endif() ``` -------------------------------- ### Build TON Trace Emulator Core Library (CMake) Source: https://github.com/toncenter/ton-index-worker/blob/main/ton-trace-emulator/CMakeLists.txt Defines a static library 'ton-trace-emulator-core' for tracing TON blockchain data. It includes source files, specifies public include directories for external TON, the project's src, and tondb-scanner, and links against necessary libraries like tondb-scanner, overlay, and emulator. It also sets the C++ standard to C++20. ```cmake cmake_minimum_required(VERSION 3.16) add_library(ton-trace-emulator-core STATIC src/TraceEmulator.cpp src/OverlayListener.cpp src/BlockEmulator.cpp src/TraceInterfaceDetector.cpp ) target_include_directories(ton-trace-emulator-core PUBLIC external/ton PUBLIC src/ PUBLIC tondb-scanner/src ) target_link_directories(ton-trace-emulator-core PUBLIC external/ton ) target_link_libraries(ton-trace-emulator-core PUBLIC tondb-scanner overlay emulator) target_compile_features(ton-trace-emulator-core PRIVATE cxx_std_20) ``` -------------------------------- ### Define Test Executable (CMake) Source: https://github.com/toncenter/ton-index-worker/blob/main/tondb-scanner/CMakeLists.txt This CMake snippet defines an executable target named 'test-tondb' for running tests. It specifies the test source file and links against necessary libraries, including the 'tondb-scanner' library and other TON components. ```cmake set(TONDB_SCANNER_TEST_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/test/tests.cpp PARENT_SCOPE ) add_executable(test-tondb test/tests.cpp ${TONDB_SCANNER_TEST_SOURCE}) target_include_directories(test-tondb PUBLIC external/ton PUBLIC src/ ) target_link_libraries(test-tondb PRIVATE tdutils tdactor smc-envelope tondb-scanner ton_block) add_dependencies(test-tondb test-tdutils) ``` -------------------------------- ### Define ton-index-worker Library (CMake) Source: https://github.com/toncenter/ton-index-worker/blob/main/tondb-scanner/CMakeLists.txt This snippet defines a static library named 'tondb-scanner' using CMake. It lists the source files for the library and sets the C++ standard to C++20. It also specifies the necessary include directories and links against several TON-related libraries. ```cmake cmake_minimum_required(VERSION 3.16) add_library(tondb-scanner STATIC src/InsertManager.cpp src/InsertManagerBase.cpp src/DbScanner.cpp src/DataParser.cpp src/TraceAssembler.cpp src/EventProcessor.cpp src/queue_state.cpp src/parse_token_data.cpp src/convert-utils.cpp src/tokens-tlb.cpp src/Statistics.cpp src/smc-interfaces/Tokens.cpp src/smc-interfaces/NftSale.cpp src/smc-interfaces/execute-smc.cpp ) target_include_directories(tondb-scanner PUBLIC src/ ) target_compile_features(tondb-scanner PRIVATE cxx_std_20) target_link_libraries(tondb-scanner PUBLIC validator-disk ton_validator tddb smc-envelope msgpack-cxx) ``` -------------------------------- ### Generate TLB Source Files (CMake Custom Command) Source: https://github.com/toncenter/ton-index-worker/blob/main/tondb-scanner/CMakeLists.txt This CMake custom command generates TLB (Type Language) source files for tokens. It uses the 'tlbc' tool to process 'tlb/tokens.tlb' and outputs 'tokens-tlb.cpp' and 'tokens-tlb.h'. This command is set up to run when the 'tlb_generate_tokens' custom target is built. ```cmake set(TLB_TOKENS ${CMAKE_CURRENT_SOURCE_DIR}/src/tokens-tlb.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/tokens-tlb.h ) add_custom_command( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src COMMAND tlbc -o tokens-tlb -n tokens::gen -z tlb/tokens.tlb COMMENT "Generate tokes tlb source files" OUTPUT ${TLB_TOKENS} DEPENDS tlbc src/tlb/tokens.tlb ) add_custom_target(tlb_generate_tokens DEPENDS ${TLB_TOKENS}) add_dependencies(tondb-scanner tlb_generate_tokens) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.