kernel: Add Handle/View pattern for BlockValidationState

Add C API functions for managing BlockValidationState lifecycle:
  - btck_block_validation_state_create()
  - btck_block_validation_state_copy()
  - btck_block_validation_state_destroy()

Introduce BlockValidationStateApi<> template to share common getter methods between BlockValidationState (Handle) and BlockValidationStateView (View) classes in the C++ wrapper. This enables external code to create and own BlockValidationState objects needed for the new process_block_header() API.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>
This commit is contained in:
yuvicc
2025-11-12 11:52:30 +05:30
parent 52096de212
commit b851ff6cae
5 changed files with 67 additions and 18 deletions

View File

@@ -885,6 +885,21 @@ const btck_BlockTreeEntry* btck_block_tree_entry_get_previous(const btck_BlockTr
return btck_BlockTreeEntry::ref(btck_BlockTreeEntry::get(entry).pprev);
}
btck_BlockValidationState* btck_block_validation_state_create()
{
return btck_BlockValidationState::create();
}
btck_BlockValidationState* btck_block_validation_state_copy(const btck_BlockValidationState* state)
{
return btck_BlockValidationState::copy(state);
}
void btck_block_validation_state_destroy(btck_BlockValidationState* state)
{
delete state;
}
btck_ValidationMode btck_block_validation_state_get_validation_mode(const btck_BlockValidationState* block_validation_state_)
{
auto& block_validation_state = btck_BlockValidationState::get(block_validation_state_);