Skip to content

Commit 6f33491

Browse files
committed
Squashed 'libbitcoinkernel-sys/bitcoin/' changes from 1ffc1c9d94b1..3d6b3fd8f65e
3d6b3fd8f65e kernel: Fix bitcoin-chainstate for windows ec099435dda4 kernel: Add Purpose section to header documentation 832689c68b5a kernel: Allowing reducing exports 969a8110a567 kernel: Add pure kernel bitcoin-chainstate 88e2f3001b65 kernel: Add functions to get the block hash from a block de4a96b341f9 kernel: Add block index utility functions to C header c3582e16a774 kernel: Add function to read block undo data from disk to C header 183b53c981e6 kernel: Add functions to read block from disk to C header d35570686946 kernel: Add function for copying block data to C header 3ac26a9911a6 kernel: Add functions for the block validation state to C header eb9a90ff5cc0 kernel: Add validation interface to C header 451558a160a2 kernel: Add interrupt function to C header 55e36cf39fdf kernel: Add import blocks function to C header 3671c91fd593 kernel: Add chainstate load options for in-memory dbs in C header 128415b1b753 kernel: Add options for reindexing in C header add8205e8e93 kernel: Add block validation to C header 1404b97942ca kernel: Add chainstate loading when instantiating a ChainstateManager 76d73226d99d kernel: Add chainstate manager option for setting worker threads 6de50dca962f kernel: Add chainstate manager object to C header 477df9b640e8 kernel: Add notifications context option to C header c3868780f525 kernel: Add chain params context option to C header 649bd3fd565e kernel: Add kernel library context object b7e24e1547ad kernel: Add logging to kernel library C header c1536041e434 kernel: Introduce initial kernel C header API REVERT: 1ffc1c9d94b1 kernel: Fix bitcoin-chainstate for windows REVERT: 686c4108cc1d kernel: Add Purpose section to header documentation REVERT: 8d47a4073120 kernel: Add pure kernel bitcoin-chainstate REVERT: ba84650882f1 kernel: Add functions to get the block hash from a block REVERT: a4217273422b kernel: Add block index utility functions to C header REVERT: aedbe73cf096 kernel: Add function to read block undo data from disk to C header REVERT: 109dda0845d8 kernel: Add functions to read block from disk to C header REVERT: 3e24c34ad481 kernel: Add function for copying block data to C header REVERT: 9ab3d14c1d15 kernel: Add functions for the block validation state to C header REVERT: 4408228f8556 kernel: Add validation interface to C header REVERT: 0c3054ef4b6e kernel: Add interrupt function to C header REVERT: 45895c4ac778 kernel: Add import blocks function to C header REVERT: 994c869ba238 kernel: Add chainstate load options for in-memory dbs in C header REVERT: b4ad47e31268 kernel: Add options for reindexing in C header REVERT: 591b28d61548 kernel: Add block validation to C header REVERT: a1fe6b4264bf kernel: Add chainstate loading when instantiating a ChainstateManager REVERT: 0cf99f827e48 kernel: Add chainstate manager option for setting worker threads REVERT: c18b35135c75 kernel: Add chainstate manager object to C header REVERT: 1de2db7eacde kernel: Add notifications context option to C header REVERT: b1e6a28d17c6 kernel: Add chain params context option to C header REVERT: 369cfd3f6c4f kernel: Add kernel library context object REVERT: f9e13dbb1ade kernel: Add logging to kernel library C header REVERT: ce1288828783 kernel: Introduce initial kernel C header API git-subtree-dir: libbitcoinkernel-sys/bitcoin git-subtree-split: 3d6b3fd8f65e8d4ea2c26d61c3dee89f5da10fac
1 parent 9997c3d commit 6f33491

File tree

7 files changed

+220
-222
lines changed

7 files changed

+220
-222
lines changed

src/bitcoin-chainstate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include <vector>
1111

1212
#ifdef WIN32
13+
// clang-format off
1314
#include <windows.h>
15+
// clang-format on
1416
#include <codecvt>
1517
#include <shellapi.h>
1618
#include <locale>

src/kernel/CMakeLists.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,15 @@ target_link_libraries(bitcoinkernel
9393
Boost::headers
9494
)
9595

96-
# libbitcoinkernel requires default symbol visibility, explicitly
97-
# specify that here so that things still work even when user
98-
# configures with -DREDUCE_EXPORTS=ON
99-
#
100-
# Note this is a quick hack that will be removed as we
101-
# incrementally define what to export from the library.
102-
set_target_properties(bitcoinkernel PROPERTIES
103-
CXX_VISIBILITY_PRESET default
104-
)
105-
10696
# Add a convenience libbitcoinkernel target as a synonym for bitcoinkernel.
10797
add_custom_target(libbitcoinkernel)
10898
add_dependencies(libbitcoinkernel bitcoinkernel)
10999

100+
get_target_property(bitcoinkernel_type bitcoinkernel TYPE)
101+
if(bitcoinkernel_type STREQUAL "STATIC_LIBRARY")
102+
target_compile_definitions(bitcoinkernel PUBLIC BITCOINKERNEL_STATIC)
103+
endif()
104+
110105
# When building the static library, install all static libraries the
111106
# bitcoinkernel depends on.
112107
if(NOT BUILD_SHARED_LIBS)

src/kernel/bitcoinkernel.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ bool kernel_verify_script(const kernel_ScriptPubkey* script_pubkey_,
505505
}
506506
spent_outputs.reserve(spent_outputs_len);
507507
for (size_t i = 0; i < spent_outputs_len; i++) {
508-
const CTxOut& tx_out{*reinterpret_cast<const CTxOut*>(spent_outputs_[i])};
508+
const CTxOut& tx_out{*cast_transaction_output(spent_outputs_[i])};
509509
spent_outputs.push_back(tx_out);
510510
}
511511
}
@@ -1041,6 +1041,7 @@ kernel_Block* kernel_block_read(const kernel_Context* context_,
10411041
auto block{new std::shared_ptr<CBlock>(new CBlock{})};
10421042
if (!chainman->m_blockman.ReadBlock(**block, *block_index)) {
10431043
LogError("Failed to read block.");
1044+
delete block;
10441045
return nullptr;
10451046
}
10461047
return reinterpret_cast<kernel_Block*>(block);
@@ -1057,12 +1058,12 @@ kernel_BlockUndo* kernel_block_undo_read(const kernel_Context* context_,
10571058
LogDebug(BCLog::KERNEL, "The genesis block does not have undo data.");
10581059
return nullptr;
10591060
}
1060-
auto block_undo{new CBlockUndo{}};
1061+
auto block_undo{std::make_unique<CBlockUndo>()};
10611062
if (!chainman->m_blockman.ReadBlockUndo(*block_undo, *block_index)) {
10621063
LogError("Failed to read block undo data.");
10631064
return nullptr;
10641065
}
1065-
return reinterpret_cast<kernel_BlockUndo*>(block_undo);
1066+
return reinterpret_cast<kernel_BlockUndo*>(block_undo.release());
10661067
}
10671068

10681069
void kernel_block_index_destroy(kernel_BlockIndex* block_index)

src/kernel/bitcoinkernel.h

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,33 @@
1515
#endif // __cplusplus
1616

1717
#ifndef BITCOINKERNEL_API
18-
#if defined(_WIN32)
19-
#ifdef BITCOINKERNEL_BUILD
20-
#define BITCOINKERNEL_API __declspec(dllexport)
21-
#else
22-
#define BITCOINKERNEL_API
23-
#endif
24-
#elif defined(__GNUC__) && defined(BITCOINKERNEL_BUILD)
25-
#define BITCOINKERNEL_API __attribute__((visibility("default")))
26-
#else
27-
#define BITCOINKERNEL_API
28-
#endif
29-
#endif
30-
31-
#if !defined(BITCOINKERNEL_GNUC_PREREQ)
32-
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
33-
#define BITCOINKERNEL_GNUC_PREREQ(_maj, _min) \
34-
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((_maj) << 16) + (_min))
35-
#else
36-
#define BITCOINKERNEL_GNUC_PREREQ(_maj, _min) 0
37-
#endif
18+
#ifdef BITCOINKERNEL_BUILD
19+
#if defined(_WIN32)
20+
#define BITCOINKERNEL_API __declspec(dllexport)
21+
#elif !defined(_WIN32) && defined(__GNUC__)
22+
#define BITCOINKERNEL_API __attribute__((visibility("default")))
23+
#else
24+
#define BITCOINKERNEL_API
25+
#endif
26+
#else
27+
#if defined(_WIN32) && !defined(BITCOINKERNEL_STATIC)
28+
#define BITCOINKERNEL_API __declspec(dllimport)
29+
#else
30+
#define BITCOINKERNEL_API
31+
#endif
32+
#endif
3833
#endif
3934

4035
/* Warning attributes */
41-
#if defined(__GNUC__) && BITCOINKERNEL_GNUC_PREREQ(3, 4)
42-
#define BITCOINKERNEL_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
36+
#if defined(__GNUC__)
37+
#define BITCOINKERNEL_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
4338
#else
44-
#define BITCOINKERNEL_WARN_UNUSED_RESULT
39+
#define BITCOINKERNEL_WARN_UNUSED_RESULT
4540
#endif
46-
#if !defined(BITCOINKERNEL_BUILD) && defined(__GNUC__) && BITCOINKERNEL_GNUC_PREREQ(3, 4)
47-
#define BITCOINKERNEL_ARG_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
41+
#if !defined(BITCOINKERNEL_BUILD) && defined(__GNUC__)
42+
#define BITCOINKERNEL_ARG_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
4843
#else
49-
#define BITCOINKERNEL_ARG_NONNULL(...)
44+
#define BITCOINKERNEL_ARG_NONNULL(...)
5045
#endif
5146

5247
#ifdef __cplusplus
@@ -130,8 +125,8 @@ typedef struct kernel_TransactionOutput kernel_TransactionOutput;
130125
*
131126
* Messages that were logged before a connection is created are buffered in a
132127
* 1MB buffer. Logging can alternatively be permanently disabled by calling
133-
* kernel_disable_logging(). Functions changing the logging settings are global
134-
* (and not thread safe) and change the settings for all existing
128+
* @ref kernel_logging_disable. Functions changing the logging settings are
129+
* global (and not thread safe) and change the settings for all existing
135130
* kernel_LoggingConnection instances.
136131
*/
137132
typedef struct kernel_LoggingConnection kernel_LoggingConnection;
@@ -576,9 +571,9 @@ BITCOINKERNEL_API void kernel_logging_disable();
576571

577572
/**
578573
* @brief Set the log level of the global internal logger. This does not
579-
* enable the selected categories. Use `kernel_enable_log_category` to start
580-
* logging from a specific, or all categories. This function is not thread
581-
* safe. Mutiple calls from different threads are allowed but must be
574+
* enable the selected categories. Use @ref kernel_logging_enable_category to
575+
* start logging from a specific, or all categories. This function is not
576+
* thread safe. Mutiple calls from different threads are allowed but must be
582577
* synchronized. This changes a global setting and will override settings for
583578
* all existing @ref kernel_LoggingConnection instances.
584579
*
@@ -786,7 +781,7 @@ BITCOINKERNEL_API void kernel_chainstate_manager_options_set_worker_threads_num(
786781

787782
/**
788783
* @brief Sets wipe db in the options. In combination with calling
789-
* @ref kernel_import_blocks this triggers either a full reindex,
784+
* @ref kernel_chainstate_manager_import_blocks this triggers either a full reindex,
790785
* or a reindex of just the chainstate database.
791786
*
792787
* @param[in] chainstate_manager_options Non-null, created by @ref kernel_chainstate_manager_options_create.

src/kernel/bitcoinkernel_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ class BlockUndo
473473
}
474474
};
475475

476-
const std::unique_ptr<kernel_BlockUndo, Deleter> m_block_undo;
476+
std::unique_ptr<kernel_BlockUndo, Deleter> m_block_undo;
477477

478478
public:
479479
const uint64_t m_size;

src/test/kernel/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ target_link_libraries(test_kernel
66
PRIVATE
77
core_interface
88
bitcoinkernel
9+
Boost::headers
910
)
1011

1112
set_target_properties(test_kernel PROPERTIES

0 commit comments

Comments
 (0)