diff --git a/chronik/CMakeLists.txt b/chronik/CMakeLists.txt --- a/chronik/CMakeLists.txt +++ b/chronik/CMakeLists.txt @@ -73,3 +73,17 @@ add_crate_test_targets(abc-rust) add_crate_test_targets(bitcoinsuite) add_crate_test_targets(chronik) + +# Chronik library +add_library(chronik + chronik-cpp/chronik.cpp +) +target_include_directories(chronik PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(chronik + util +) + +# Add chronik to server +target_link_libraries(server + chronik +) diff --git a/chronik/chronik-cpp/chronik.h b/chronik/chronik-cpp/chronik.h new file mode 100644 --- /dev/null +++ b/chronik/chronik-cpp/chronik.h @@ -0,0 +1,21 @@ +// Copyright (c) 2022 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CHRONIK_CPP_CHRONIK_H +#define BITCOIN_CHRONIK_CPP_CHRONIK_H + +class Config; +struct NodeContext; + +namespace chronik { + +// Registers Chronik indexer as ValidationInterface, listens to HTTP queries +void Start(const Config &config, const NodeContext &node); + +// Unregisters Chronik indexer as ValidationInterface, stops the HTTP server +void Stop(); + +} // namespace chronik + +#endif // BITCOIN_CHRONIK_CPP_CHRONIK_H diff --git a/chronik/chronik-cpp/chronik.cpp b/chronik/chronik-cpp/chronik.cpp new file mode 100644 --- /dev/null +++ b/chronik/chronik-cpp/chronik.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2022 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include + +#include + +namespace chronik { + +void Start([[maybe_unused]] const Config &config, + [[maybe_unused]] const NodeContext &node) { + LogPrintf("Starting Chronik...\n"); +} + +void Stop() { LogPrintf("Stopping Chronik...\n"); } + +} // namespace chronik diff --git a/contrib/teamcity/build-configurations.yml b/contrib/teamcity/build-configurations.yml --- a/contrib/teamcity/build-configurations.yml +++ b/contrib/teamcity/build-configurations.yml @@ -103,6 +103,10 @@ - '-DBUILD_BITCOIN_CHRONIK=ON' targets: - - check-crates + - - all + - install + - - check + - check-functional build-clang: Werror: true diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -73,6 +73,10 @@ #include #include +#if ENABLE_CHRONIK +#include +#endif + #if ENABLE_ZMQ #include #include @@ -227,6 +231,10 @@ node.connman->Stop(); } +#if ENABLE_CHRONIK + chronik::Stop(); +#endif + StopTorControl(); // After everything has been shut down, but before things get flushed, stop @@ -2910,6 +2918,11 @@ /* cache size */ 0, false, fReindex); g_coin_stats_index->Start(chainman.ActiveChainstate()); } + +#if ENABLE_CHRONIK + chronik::Start(config, node); +#endif + // Step 9: load wallet for (const auto &client : node.chain_clients) { if (!client->load()) {