From 4dd7e6dc48ed3a97856a19ca15078366cd0b8056 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Thu, 6 Nov 2025 17:34:12 +0000 Subject: [PATCH] kernel: remove btck_chain_get_genesis It is equivalent to calling btck_chain_get_by_height(0). --- src/kernel/bitcoinkernel.cpp | 6 ------ src/kernel/bitcoinkernel.h | 9 --------- src/kernel/bitcoinkernel_wrapper.h | 5 ----- src/test/kernel/test_kernel.cpp | 2 +- 4 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp index 8bba3cf1c0c..ee1bb985a88 100644 --- a/src/kernel/bitcoinkernel.cpp +++ b/src/kernel/bitcoinkernel.cpp @@ -1242,12 +1242,6 @@ int btck_chain_get_height(const btck_Chain* chain) return btck_Chain::get(chain).Height(); } -const btck_BlockTreeEntry* btck_chain_get_genesis(const btck_Chain* chain) -{ - LOCK(::cs_main); - return btck_BlockTreeEntry::ref(btck_Chain::get(chain).Genesis()); -} - const btck_BlockTreeEntry* btck_chain_get_by_height(const btck_Chain* chain, int height) { LOCK(::cs_main); diff --git a/src/kernel/bitcoinkernel.h b/src/kernel/bitcoinkernel.h index add45f4b47e..3875832ef6c 100644 --- a/src/kernel/bitcoinkernel.h +++ b/src/kernel/bitcoinkernel.h @@ -1222,15 +1222,6 @@ BITCOINKERNEL_API const btck_BlockTreeEntry* BITCOINKERNEL_WARN_UNUSED_RESULT bt BITCOINKERNEL_API int32_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_get_height( const btck_Chain* chain) BITCOINKERNEL_ARG_NONNULL(1); -/** - * @brief Get the block tree entry of the genesis block. - * - * @param[in] chain Non-null. - * @return The block tree entry of the genesis block, or null if the chain is empty. - */ -BITCOINKERNEL_API const btck_BlockTreeEntry* BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_get_genesis( - const btck_Chain* chain) BITCOINKERNEL_ARG_NONNULL(1); - /** * @brief Retrieve a block tree entry by its height in the currently active chain. * Once retrieved there is no guarantee that it remains in the active chain. diff --git a/src/kernel/bitcoinkernel_wrapper.h b/src/kernel/bitcoinkernel_wrapper.h index 06a4ccfaa01..7bc3dd7821c 100644 --- a/src/kernel/bitcoinkernel_wrapper.h +++ b/src/kernel/bitcoinkernel_wrapper.h @@ -982,11 +982,6 @@ public: return btck_chain_get_height(get()) + 1; } - BlockTreeEntry Genesis() const - { - return btck_chain_get_genesis(get()); - } - BlockTreeEntry GetByHeight(int height) const { auto index{btck_chain_get_by_height(get(), height)}; diff --git a/src/test/kernel/test_kernel.cpp b/src/test/kernel/test_kernel.cpp index d9875ee16e0..eba1eb81072 100644 --- a/src/test/kernel/test_kernel.cpp +++ b/src/test/kernel/test_kernel.cpp @@ -664,7 +664,7 @@ void chainman_reindex_test(TestDirectory& test_directory) // Sanity check some block retrievals auto chain{chainman->GetChain()}; BOOST_CHECK_THROW(chain.GetByHeight(1000), std::runtime_error); - auto genesis_index{chain.Genesis()}; + auto genesis_index{chain.Entries().front()}; BOOST_CHECK(!genesis_index.GetPrevious()); auto genesis_block_raw{chainman->ReadBlock(genesis_index).value().ToBytes()}; auto first_index{chain.GetByHeight(0)};