From fa51594c5c0fe27e55d580dfab046e1226c6d83b Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Mon, 2 Feb 2026 15:05:22 +0100 Subject: [PATCH] refactor: Small style fixups in src/kernel/bitcoinkernel.cpp * Use type alias TranslateFn: https://github.com/bitcoin/bitcoin/pull/30595#discussion_r2653828562 * Use std::span::data: https://github.com/bitcoin/bitcoin/pull/30595#discussion_r2653829743 * Use the ref helper: https://github.com/bitcoin/bitcoin/pull/30595#discussion_r2653829991 * Reword error handling section: https://github.com/bitcoin/bitcoin/pull/30595#discussion_r2653843805 --- src/kernel/bitcoinkernel.cpp | 9 ++++----- src/kernel/bitcoinkernel.h | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp index c8189b629b6..ea646cd551f 100644 --- a/src/kernel/bitcoinkernel.cpp +++ b/src/kernel/bitcoinkernel.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -56,7 +55,7 @@ using util::ImmediateTaskRunner; // Define G_TRANSLATION_FUN symbol in libbitcoinkernel library so users of the // library aren't required to export this symbol -extern const std::function G_TRANSLATION_FUN{nullptr}; +extern const TranslateFn G_TRANSLATION_FUN{nullptr}; static const kernel::Context btck_context_static{}; @@ -84,7 +83,7 @@ public: // void write(std::span src) { - if (m_writer(std::data(src), src.size(), m_user_data) != 0) { + if (m_writer(src.data(), src.size(), m_user_data) != 0) { throw std::runtime_error("Failed to write serialization data"); } } @@ -113,13 +112,13 @@ struct Handle { static C* create(Args&&... args) { auto cpp_obj{std::make_unique(std::forward(args)...)}; - return reinterpret_cast(cpp_obj.release()); + return ref(cpp_obj.release()); } static C* copy(const C* ptr) { auto cpp_obj{std::make_unique(get(ptr))}; - return reinterpret_cast(cpp_obj.release()); + return ref(cpp_obj.release()); } static const CPP& get(const C* ptr) diff --git a/src/kernel/bitcoinkernel.h b/src/kernel/bitcoinkernel.h index a7f09dd3a40..5427e776177 100644 --- a/src/kernel/bitcoinkernel.h +++ b/src/kernel/bitcoinkernel.h @@ -82,9 +82,9 @@ extern "C" { * @section error Error handling * * Functions communicate an error through their return types, usually returning - * a nullptr, 0, or false if an error is encountered. Additionally, verification - * functions, e.g. for scripts, may communicate more detailed error information - * through status code out parameters. + * a nullptr or a status code as documented by the returning function. + * Additionally, verification functions, e.g. for scripts, may communicate more + * detailed error information through status code out parameters. * * Fine-grained validation information is communicated through the validation * interface.