mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-15 08:23:46 +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:
@@ -885,6 +885,13 @@ const btck_BlockTreeEntry* btck_block_tree_entry_get_previous(const btck_BlockTr
|
||||
return btck_BlockTreeEntry::ref(btck_BlockTreeEntry::get(entry).pprev);
|
||||
}
|
||||
|
||||
const btck_BlockTreeEntry* btck_block_tree_entry_get_ancestor(const btck_BlockTreeEntry* block_tree_entry, int32_t height)
|
||||
{
|
||||
const auto* ancestor{btck_BlockTreeEntry::get(block_tree_entry).GetAncestor(height)};
|
||||
assert(ancestor);
|
||||
return btck_BlockTreeEntry::ref(ancestor);
|
||||
}
|
||||
|
||||
btck_BlockValidationState* btck_block_validation_state_create()
|
||||
{
|
||||
return btck_BlockValidationState::create();
|
||||
|
||||
Reference in New Issue
Block a user