mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
kernel: expose btck_block_tree_entry_get_ancestor
Allows callers to jump to any ancestor of a block tree entry by height using the skiplist-backed GetAncestor, which runs in O(log N) rather than walking back one entry at a time with btck_block_tree_entry_get_previous. Includes a C++ convenience wrapper and tests in btck_block_tree_entry_tests.
This commit is contained in:
@@ -973,6 +973,11 @@ BOOST_AUTO_TEST_CASE(btck_block_tree_entry_tests)
|
||||
auto prev{entry_1.GetPrevious()};
|
||||
BOOST_CHECK(prev.has_value());
|
||||
BOOST_CHECK(prev.value() == entry_0);
|
||||
|
||||
// Test GetAncestor
|
||||
BOOST_CHECK(entry_2.GetAncestor(2) == entry_2);
|
||||
BOOST_CHECK(entry_2.GetAncestor(1) == entry_1);
|
||||
BOOST_CHECK(entry_2.GetAncestor(0) == entry_0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(btck_chainman_in_memory_tests)
|
||||
|
||||
Reference in New Issue
Block a user