Skip to content

Commit 24563d2

Browse files
committed
Squashed 'libbitcoinkernel-sys/bitcoin/' changes from f1b3ab751bf..fc67047b7e1
fc67047b7e1 kernel: Add pure kernel bitcoin-chainstate e2116031253 kernel: Add functions to get the block hash from a block 2ae6547941f kernel: Add block index utility functions to C header f09d42fff2b kernel: Add function to read block undo data from disk to C header 52aedd024b0 kernel: Add functions to read block from disk to C header 6d2bdce9923 kernel: Add function for copying block data to C header e3b16b2677a kernel: Add functions for the block validation state to C header 8de0bd040f4 kernel: Add validation interface to C header 84abd35f72a kernel: Add interrupt function to C header 260fb3e0584 kernel: Add import blocks function to C header 971bb20e9c8 kernel: Add chainstate load options for in-memory dbs in C header 1af8c906fc7 kernel: Add options for reindexing in C header 055d2ed419e kernel: Add block validation to C header 39850656a04 Kernel: Add chainstate loading to kernel C header 06d26f0bfa6 kernel: Add chainstate manager option for setting worker threads a3d46f4bf64 kernel: Add chainstate manager object to C header d2e2da933b7 kernel: Add notifications context option to C header 1337539a0b3 kerenl: Add chain params context option to C header 778330c21f0 kernel: Add kernel library context object a54b59d8100 kernel: Add logging to kernel library C header 4fe7162698d kernel: Introduce initial kernel C header API REVERT: f1b3ab751bf kernel: Add pure kernel bitcoin-chainstate REVERT: 47c0497f899 kernel: Add functions to get the block hash from a block REVERT: bf051407293 kernel: Add block index utility functions to C header REVERT: 0dc1261a394 kernel: Add function to read block undo data from disk to C header REVERT: 8ae118d85d9 kernel: Add functions to read block from disk to C header REVERT: d757da1e777 kernel: Add function for copying block data to C header REVERT: c7625645ffa kernel: Add functions for the block validation state to C header REVERT: 085ab7e71c2 kernel: Add validation interface to C header REVERT: d8b7cf099d3 kernel: Add interrupt function to C header REVERT: 018613752ad kernel: Add import blocks function to C header REVERT: 8fc00b9fcac kernel: Add chainstate load options for in-memory dbs in C header REVERT: a9bb48476ed kernel: Add options for reindexing in C header REVERT: 94bd5138dac kernel: Add block validation to C header REVERT: c399b61f226 Kernel: Add chainstate loading to kernel C header REVERT: feede0a425b kernel: Add chainstate manager option for setting worker threads REVERT: 583820c4487 kernel: Add chainstate manager object to C header REVERT: ec137a086a0 kernel: Add notifications context option to C header REVERT: 62a89689266 kerenl: Add chain params context option to C header REVERT: bb482dcbd30 kernel: Add kernel library context object REVERT: d114ccfdf8a kernel: Add logging to kernel library C header REVERT: 44c65c46c43 kernel: Introduce initial kernel C header API git-subtree-dir: libbitcoinkernel-sys/bitcoin git-subtree-split: fc67047b7e1fb7031285f790ea3a7ea349474f31
1 parent b314fdd commit 24563d2

File tree

5 files changed

+59
-54
lines changed

5 files changed

+59
-54
lines changed

src/kernel/bitcoin-chainstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class TestValidationInterface : public ValidationInterface<TestValidationInterfa
9191
class TestKernelNotifications : public KernelNotifications<TestKernelNotifications>
9292
{
9393
public:
94-
void BlockTipHandler(kernel_SynchronizationState state, kernel_BlockIndex* index) override
94+
void BlockTipHandler(kernel_SynchronizationState state, const kernel_BlockIndex* index) override
9595
{
9696
std::cout << "Block tip changed" << std::endl;
9797
}

src/kernel/bitcoinkernel.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,28 +167,28 @@ class KernelNotifications : public kernel::Notifications
167167

168168
kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) override
169169
{
170-
if (m_cbs.block_tip) m_cbs.block_tip(m_cbs.user_data, cast_state(state), reinterpret_cast<kernel_BlockIndex*>(&index));
170+
if (m_cbs.block_tip) m_cbs.block_tip((void*) m_cbs.user_data, cast_state(state), reinterpret_cast<const kernel_BlockIndex*>(&index));
171171
return {};
172172
}
173173
void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override
174174
{
175-
if (m_cbs.header_tip) m_cbs.header_tip(m_cbs.user_data, cast_state(state), height, timestamp, presync);
175+
if (m_cbs.header_tip) m_cbs.header_tip((void*) m_cbs.user_data, cast_state(state), height, timestamp, presync);
176176
}
177177
void warningSet(kernel::Warning id, const bilingual_str& message) override
178178
{
179-
if (m_cbs.warning_set) m_cbs.warning_set(m_cbs.user_data, cast_kernel_warning(id), message.original.c_str());
179+
if (m_cbs.warning_set) m_cbs.warning_set((void*) m_cbs.user_data, cast_kernel_warning(id), message.original.c_str());
180180
}
181181
void warningUnset(kernel::Warning id) override
182182
{
183-
if (m_cbs.warning_unset) m_cbs.warning_unset(m_cbs.user_data, cast_kernel_warning(id));
183+
if (m_cbs.warning_unset) m_cbs.warning_unset((void*) m_cbs.user_data, cast_kernel_warning(id));
184184
}
185185
void flushError(const bilingual_str& message) override
186186
{
187-
if (m_cbs.flush_error) m_cbs.flush_error(m_cbs.user_data, message.original.c_str());
187+
if (m_cbs.flush_error) m_cbs.flush_error((void*) m_cbs.user_data, message.original.c_str());
188188
}
189189
void fatalError(const bilingual_str& message) override
190190
{
191-
if (m_cbs.fatal_error) m_cbs.fatal_error(m_cbs.user_data, message.original.c_str());
191+
if (m_cbs.fatal_error) m_cbs.fatal_error((void*) m_cbs.user_data, message.original.c_str());
192192
}
193193
};
194194

@@ -245,7 +245,7 @@ class KernelValidationInterface final : public CValidationInterface
245245
void BlockChecked(const CBlock& block, const BlockValidationState& stateIn) override
246246
{
247247
if (m_cbs.block_checked) {
248-
m_cbs.block_checked(m_cbs.user_data,
248+
m_cbs.block_checked((void*) m_cbs.user_data,
249249
reinterpret_cast<const kernel_BlockPointer*>(&block),
250250
reinterpret_cast<const kernel_BlockValidationState*>(&stateIn));
251251
}
@@ -511,7 +511,7 @@ void kernel_disable_logging()
511511
}
512512

513513
kernel_LoggingConnection* kernel_logging_connection_create(kernel_LogCallback callback,
514-
void* user_data,
514+
const void* user_data,
515515
const kernel_LoggingOptions options)
516516
{
517517
LogInstance().m_log_timestamps = options.log_timestamps;
@@ -520,7 +520,7 @@ kernel_LoggingConnection* kernel_logging_connection_create(kernel_LogCallback ca
520520
LogInstance().m_log_sourcelocations = options.log_sourcelocations;
521521
LogInstance().m_always_print_category_level = options.always_print_category_levels;
522522

523-
auto connection{LogInstance().PushBackCallback([callback, user_data](const std::string& str) { callback(user_data, str.c_str()); })};
523+
auto connection{LogInstance().PushBackCallback([callback, user_data](const std::string& str) { callback((void*) user_data, str.c_str()); })};
524524

525525
try {
526526
// Only start logging if we just added the connection.
@@ -783,9 +783,9 @@ void kernel_block_manager_options_destroy(kernel_BlockManagerOptions* options)
783783
}
784784

785785
kernel_ChainstateManager* kernel_chainstate_manager_create(
786+
const kernel_Context* context_,
786787
kernel_ChainstateManagerOptions* chainman_opts_,
787-
kernel_BlockManagerOptions* blockman_opts_,
788-
const kernel_Context* context_)
788+
kernel_BlockManagerOptions* blockman_opts_)
789789
{
790790
auto chainman_opts{cast_chainstate_manager_options(chainman_opts_)};
791791
auto blockman_opts{cast_block_manager_options(blockman_opts_)};

src/kernel/bitcoinkernel.h

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#define BITCOINKERNEL_WARN_UNUSED_RESULT
3232
#endif
3333
#if !defined(BITCOINKERNEL_BUILD) && defined(__GNUC__) && BITCOINKERNEL_GNUC_PREREQ(3, 4)
34-
#define BITCOINKERNEL_ARG_NONNULL(_x) __attribute__((__nonnull__(_x)))
34+
#define BITCOINKERNEL_ARG_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
3535
#else
3636
#define BITCOINKERNEL_ARG_NONNULL(_x)
3737
#endif
@@ -43,13 +43,14 @@ extern "C" {
4343
/**
4444
* ------ Context ------
4545
*
46-
* The library provides a built-in static constant kernel context. This context
47-
* offers only limited functionality. It detects and self-checks the correct
48-
* sha256 implementation, initializes the random number generator and
49-
* self-checks the secp256k1 static context. It is used internally for otherwise
50-
* "context-free" operations.
46+
* The library provides a built-in static constant kernel context. This static
47+
* context offers only limited functionality. It detects and self-checks the
48+
* correct sha256 implementation, initializes the random number generator and
49+
* self-checks the secp256k1 static context. It is used internally for
50+
* otherwise "context-free" operations. This means that the user is not
51+
* required to initialize their own context before using the library.
5152
*
52-
* The user can create their own context for passing it to state-rich validation
53+
* The user should create their own context for passing it to state-rich validation
5354
* functions and holding callbacks for kernel events.
5455
*
5556
* ------ Error handling ------
@@ -73,11 +74,13 @@ extern "C" {
7374
* returned by functions. Typically pointers returned by *_create(...) functions
7475
* can be de-allocated by corresponding *_destroy(...) functions.
7576
*
76-
* Pointer arguments make no assumptions on their lifetime. Once the function
77-
* returns the user can safely de-allocate the passed in arguments.
77+
* A function that takes pointer arguments makes no assumptions on their
78+
* lifetime. Once the function returns the user can safely de-allocate the
79+
* passed in arguments.
7880
*
79-
* Pointers passed by callbacks are not owned by the user and are only valid for
80-
* the duration of it. They should not be de-allocated by the user.
81+
* Pointers passed by callbacks are not owned by the user and are only valid
82+
* for the duration of the callback. They are always marked as `const` and must
83+
* not be de-allocated by the user.
8184
*
8285
* Array lengths follow the pointer argument they describe.
8386
*/
@@ -128,8 +131,9 @@ typedef struct kernel_Notifications kernel_Notifications;
128131
*
129132
* Once a kernel context has been created from these options, they may be
130133
* destroyed. The options hold the notification callbacks as well as the
131-
* selected chain type until they are passed to the context. Their content and
132-
* scope can be expanded over time.
134+
* selected chain type until they are passed to the context. If no options are
135+
* configured, the context will be instantiated with no callbacks and for
136+
* mainnet. Their content and scope can be expanded over time.
133137
*/
134138
typedef struct kernel_ContextOptions kernel_ContextOptions;
135139

@@ -266,7 +270,7 @@ typedef void (*kernel_LogCallback)(void* user_data, const char* message);
266270
/**
267271
* Function signatures for the kernel notifications.
268272
*/
269-
typedef void (*kernel_NotifyBlockTip)(void* user_data, kernel_SynchronizationState state, kernel_BlockIndex* index);
273+
typedef void (*kernel_NotifyBlockTip)(void* user_data, kernel_SynchronizationState state, const kernel_BlockIndex* index);
270274
typedef void (*kernel_NotifyHeaderTip)(void* user_data, kernel_SynchronizationState state, int64_t height, int64_t timestamp, bool presync);
271275
typedef void (*kernel_NotifyProgress)(void* user_data, const char* title, int progress_percent, bool resume_possible);
272276
typedef void (*kernel_NotifyWarningSet)(void* user_data, kernel_Warning warning, const char* message);
@@ -311,7 +315,7 @@ typedef enum {
311315
* callbacks easier.
312316
*/
313317
typedef struct {
314-
void* user_data; //!< Holds a user-defined opaque structure that is passed to the validation
318+
const void* user_data; //!< Holds a user-defined opaque structure that is passed to the validation
315319
//!< interface callbacks.
316320
kernel_ValidationInterfaceBlockChecked block_checked; //!< Called when a new block has been checked. Contains the
317321
//!< result of its validation.
@@ -326,7 +330,7 @@ typedef struct {
326330
* safe unwinding.
327331
*/
328332
typedef struct {
329-
void* user_data; //!< Holds a user-defined opaque structure that is passed to the notification callbacks.
333+
const void* user_data; //!< Holds a user-defined opaque structure that is passed to the notification callbacks.
330334
kernel_NotifyBlockTip block_tip; //!< The chain's tip was updated to the provided block index.
331335
kernel_NotifyHeaderTip header_tip; //!< A new best block header was added.
332336
kernel_NotifyProgress progress; //!< Reports on current block synchronization progress.
@@ -493,7 +497,8 @@ void kernel_transaction_output_destroy(kernel_TransactionOutput* transaction_out
493497

494498
/**
495499
* @brief Verify if the input at input_index of tx_to spends the script pubkey
496-
* under the constraints specified by flags. If the witness flag is set the
500+
* under the constraints specified by flags. If the
501+
* `kernel_SCRIPT_FLAGS_VERIFY_WITNESS` flag is set in the flags bitfield, the
497502
* amount parameter is used. If the taproot flag is set, the spent outputs
498503
* parameter is used to validate taproot transactions.
499504
*
@@ -518,7 +523,7 @@ bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_verify_script(
518523
unsigned int input_index,
519524
unsigned int flags,
520525
kernel_ScriptVerifyStatus* status
521-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(3);
526+
) BITCOINKERNEL_ARG_NONNULL(1, 3);
522527

523528
/**
524529
* @brief This disables the global internal logger. No log messages will be
@@ -570,7 +575,7 @@ bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_disable_log_category(const kernel_L
570575
*/
571576
kernel_LoggingConnection* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_logging_connection_create(
572577
kernel_LogCallback callback,
573-
void* user_data,
578+
const void* user_data,
574579
const kernel_LoggingOptions options
575580
) BITCOINKERNEL_ARG_NONNULL(1);
576581

@@ -622,7 +627,7 @@ kernel_ContextOptions* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_context_options_c
622627
void kernel_context_options_set_chainparams(
623628
kernel_ContextOptions* context_options,
624629
const kernel_ChainParameters* chain_parameters
625-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
630+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
626631

627632
/**
628633
* @brief Set the kernel notifications for the context options. The context
@@ -634,7 +639,7 @@ void kernel_context_options_set_chainparams(
634639
void kernel_context_options_set_notifications(
635640
kernel_ContextOptions* context_options,
636641
const kernel_Notifications* notifications
637-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
642+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
638643

639644
/**
640645
* Destroy the context options.
@@ -682,7 +687,7 @@ void kernel_context_destroy(kernel_Context* context);
682687
kernel_ChainstateManagerOptions* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_chainstate_manager_options_create(
683688
const kernel_Context* context,
684689
const char* data_directory
685-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
690+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
686691

687692
/**
688693
* Destroy the chainstate manager options.
@@ -703,7 +708,7 @@ void kernel_chainstate_manager_options_destroy(kernel_ChainstateManagerOptions*
703708
kernel_BlockManagerOptions* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_block_manager_options_create(
704709
const kernel_Context* context,
705710
const char* blocks_directory
706-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
711+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
707712

708713
/**
709714
* @brief Set the number of available worker threads used during validation.
@@ -735,10 +740,10 @@ void kernel_block_manager_options_destroy(kernel_BlockManagerOptions* block_mana
735740
* @return The allocated chainstate manager, or null on error.
736741
*/
737742
kernel_ChainstateManager* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_chainstate_manager_create(
743+
const kernel_Context* context,
738744
kernel_ChainstateManagerOptions* chainstate_manager_options,
739-
kernel_BlockManagerOptions* block_manager_options,
740-
const kernel_Context* context
741-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2) BITCOINKERNEL_ARG_NONNULL(3);
745+
kernel_BlockManagerOptions* block_manager_options
746+
) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
742747

743748
/**
744749
* Destroy the chainstate manager.
@@ -770,7 +775,7 @@ kernel_ValidationInterface* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_validation_i
770775
bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_validation_interface_register(
771776
kernel_Context* context,
772777
kernel_ValidationInterface* validation_interface
773-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
778+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
774779

775780
/**
776781
* @brief Unregister a validation interface from the internal task runner
@@ -784,7 +789,7 @@ bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_validation_interface_register(
784789
bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_validation_interface_unregister(
785790
kernel_Context* context,
786791
kernel_ValidationInterface* validation_interface
787-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
792+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
788793

789794
/**
790795
* Destroy the validation interface. This should be done after unregistering it
@@ -860,7 +865,7 @@ bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_chainstate_manager_load_chainstate(
860865
const kernel_Context* context,
861866
kernel_ChainstateLoadOptions* chainstate_load_options,
862867
kernel_ChainstateManager* chainstate_manager
863-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2) BITCOINKERNEL_ARG_NONNULL(3);
868+
) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
864869

865870
/**
866871
* @brief May be called after kernel_chainstate_manager_load_chainstate to
@@ -877,7 +882,7 @@ bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_chainstate_manager_load_chainstate(
877882
bool kernel_import_blocks(const kernel_Context* context,
878883
kernel_ChainstateManager* chainstate_manager,
879884
const char** block_file_paths, size_t block_file_paths_len
880-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
885+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
881886

882887
/**
883888
* @brief Process and validate the passed in block with the chainstate
@@ -897,7 +902,7 @@ bool BITCOINKERNEL_WARN_UNUSED_RESULT kernel_chainstate_manager_process_block(
897902
kernel_ChainstateManager* chainstate_manager,
898903
kernel_Block* block,
899904
bool* new_block
900-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2) BITCOINKERNEL_ARG_NONNULL(3);
905+
) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
901906

902907
/**
903908
* @brief Parse a serialized raw block into a new block object.
@@ -985,7 +990,7 @@ kernel_BlockValidationResult kernel_get_block_validation_result_from_block_valid
985990
kernel_BlockIndex* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_get_block_index_from_tip(
986991
const kernel_Context* context,
987992
kernel_ChainstateManager* chainstate_manager
988-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
993+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
989994

990995
/**
991996
* @brief Get the block index entry of the genesis block.
@@ -997,7 +1002,7 @@ kernel_BlockIndex* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_get_block_index_from_
9971002
kernel_BlockIndex* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_get_block_index_from_genesis(
9981003
const kernel_Context* context,
9991004
kernel_ChainstateManager* chainstate_manager
1000-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
1005+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
10011006

10021007
/**
10031008
* @brief Retrieve a block index by its block hash.
@@ -1011,7 +1016,7 @@ kernel_BlockIndex* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_get_block_index_by_ha
10111016
const kernel_Context* context,
10121017
kernel_ChainstateManager* chainstate_manager,
10131018
kernel_BlockHash* block_hash
1014-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2) BITCOINKERNEL_ARG_NONNULL(3);
1019+
) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
10151020

10161021
/**
10171022
* @brief Retrieve a block index by its height in the currently active chain.
@@ -1026,7 +1031,7 @@ kernel_BlockIndex* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_get_block_index_by_he
10261031
const kernel_Context* context,
10271032
kernel_ChainstateManager* chainstate_manager,
10281033
int block_height
1029-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2);
1034+
) BITCOINKERNEL_ARG_NONNULL(1, 2);
10301035

10311036
/**
10321037
* @brief Return the next block index in the currently active chain, or null if
@@ -1042,7 +1047,7 @@ kernel_BlockIndex* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_get_next_block_index(
10421047
const kernel_Context* context,
10431048
kernel_BlockIndex* block_index,
10441049
kernel_ChainstateManager* chainstate_manager
1045-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2) BITCOINKERNEL_ARG_NONNULL(3);
1050+
) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
10461051

10471052
/**
10481053
* @brief Returns the previous block index in the chain, or null if the current
@@ -1068,7 +1073,7 @@ kernel_Block* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_read_block_from_disk(
10681073
const kernel_Context* context,
10691074
kernel_ChainstateManager* chainstate_manager,
10701075
kernel_BlockIndex* block_index
1071-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2) BITCOINKERNEL_ARG_NONNULL(3);
1076+
) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
10721077

10731078
/**
10741079
* @brief Reads the block undo data the passed in block index points to from
@@ -1083,7 +1088,7 @@ kernel_BlockUndo* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_read_block_undo_from_d
10831088
const kernel_Context* context,
10841089
kernel_ChainstateManager* chainstate_manager,
10851090
kernel_BlockIndex* block_index
1086-
) BITCOINKERNEL_ARG_NONNULL(1) BITCOINKERNEL_ARG_NONNULL(2) BITCOINKERNEL_ARG_NONNULL(3);
1091+
) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
10871092

10881093
/**
10891094
* @brief Destroy the block index.

src/kernel/bitcoinkernel_wrapper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class KernelNotifications
183183
{
184184
return kernel_NotificationInterfaceCallbacks{
185185
.user_data = this,
186-
.block_tip = [](void* user_data, kernel_SynchronizationState state, kernel_BlockIndex* index) {
186+
.block_tip = [](void* user_data, kernel_SynchronizationState state, const kernel_BlockIndex* index) {
187187
static_cast<T*>(user_data)->BlockTipHandler(state, index);
188188
},
189189
.header_tip = [](void* user_data, kernel_SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {
@@ -208,7 +208,7 @@ class KernelNotifications
208208

209209
virtual ~KernelNotifications() = default;
210210

211-
virtual void BlockTipHandler(kernel_SynchronizationState state, kernel_BlockIndex* index) {}
211+
virtual void BlockTipHandler(kernel_SynchronizationState state, const kernel_BlockIndex* index) {}
212212

213213
virtual void HeaderTipHandler(kernel_SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
214214

@@ -622,7 +622,7 @@ class ChainMan
622622

623623
public:
624624
ChainMan(const Context& context, const ChainstateManagerOptions& chainman_opts, const BlockManagerOptions& blockman_opts) noexcept
625-
: m_chainman{kernel_chainstate_manager_create(chainman_opts.m_options.get(), blockman_opts.m_options.get(), context.m_context.get())},
625+
: m_chainman{kernel_chainstate_manager_create(context.m_context.get(), chainman_opts.m_options.get(), blockman_opts.m_options.get())},
626626
m_context{context}
627627
{
628628
}

src/test/kernel/test_kernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct TestDirectory {
7676
class TestKernelNotifications : public KernelNotifications<TestKernelNotifications>
7777
{
7878
public:
79-
void BlockTipHandler(kernel_SynchronizationState state, kernel_BlockIndex* index) override
79+
void BlockTipHandler(kernel_SynchronizationState state, const kernel_BlockIndex* index) override
8080
{
8181
std::cout << "Block tip changed" << std::endl;
8282
}

0 commit comments

Comments
 (0)