mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-16 17:48:59 +02:00
kernel: remove btck_chain_get_tip
It is equivalent to calling btck_chain_get_by_height with the height obtained from btck_chain_get_height. In neither case do we provide guarantees that the returned block index still corresponds to the actual tip.
This commit is contained in:
@@ -1230,12 +1230,6 @@ const btck_Chain* btck_chainstate_manager_get_active_chain(const btck_Chainstate
|
||||
return btck_Chain::ref(&WITH_LOCK(btck_ChainstateManager::get(chainman).m_chainman->GetMutex(), return btck_ChainstateManager::get(chainman).m_chainman->ActiveChain()));
|
||||
}
|
||||
|
||||
const btck_BlockTreeEntry* btck_chain_get_tip(const btck_Chain* chain)
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
return btck_BlockTreeEntry::ref(btck_Chain::get(chain).Tip());
|
||||
}
|
||||
|
||||
int btck_chain_get_height(const btck_Chain* chain)
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
|
||||
@@ -1203,16 +1203,6 @@ BITCOINKERNEL_API btck_BlockValidationResult btck_block_validation_state_get_blo
|
||||
*/
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Get the block tree entry of the current chain tip. Once returned,
|
||||
* there is no guarantee that it remains in the active chain.
|
||||
*
|
||||
* @param[in] chain Non-null.
|
||||
* @return The block tree entry of the current tip, or null if the chain is empty.
|
||||
*/
|
||||
BITCOINKERNEL_API const btck_BlockTreeEntry* BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_get_tip(
|
||||
const btck_Chain* chain) BITCOINKERNEL_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Return the height of the tip of the chain.
|
||||
*
|
||||
|
||||
@@ -967,11 +967,6 @@ class ChainView : public View<btck_Chain>
|
||||
public:
|
||||
explicit ChainView(const btck_Chain* ptr) : View{ptr} {}
|
||||
|
||||
BlockTreeEntry Tip() const
|
||||
{
|
||||
return btck_chain_get_tip(get());
|
||||
}
|
||||
|
||||
int32_t Height() const
|
||||
{
|
||||
return btck_chain_get_height(get());
|
||||
|
||||
@@ -676,7 +676,7 @@ void chainman_reindex_test(TestDirectory& test_directory)
|
||||
auto next_index{chain.GetByHeight(first_index.GetHeight() + 1)};
|
||||
BOOST_CHECK(chain.Contains(next_index));
|
||||
auto next_block_data{chainman->ReadBlock(next_index).value().ToBytes()};
|
||||
auto tip_index{chain.Tip()};
|
||||
auto tip_index{chain.Entries().back()};
|
||||
auto tip_block_data{chainman->ReadBlock(tip_index).value().ToBytes()};
|
||||
auto second_index{chain.GetByHeight(1)};
|
||||
auto second_block{chainman->ReadBlock(second_index).value()};
|
||||
@@ -755,7 +755,7 @@ void chainman_mainnet_validation_test(TestDirectory& test_directory)
|
||||
|
||||
auto chain{chainman->GetChain()};
|
||||
BOOST_CHECK_EQUAL(chain.Height(), 1);
|
||||
auto tip{chain.Tip()};
|
||||
auto tip{chain.Entries().back()};
|
||||
auto read_block{chainman->ReadBlock(tip)};
|
||||
BOOST_REQUIRE(read_block);
|
||||
check_equal(read_block.value().ToBytes(), raw_block);
|
||||
@@ -851,7 +851,7 @@ BOOST_AUTO_TEST_CASE(btck_chainman_regtest_tests)
|
||||
}
|
||||
|
||||
auto chain = chainman->GetChain();
|
||||
auto tip = chain.Tip();
|
||||
auto tip = chain.Entries().back();
|
||||
auto read_block = chainman->ReadBlock(tip).value();
|
||||
check_equal(read_block.ToBytes(), hex_string_to_byte_vec(REGTEST_BLOCK_DATA[REGTEST_BLOCK_DATA.size() - 1]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user