forked from EvergreenCrypto/docker-finance
container: plugins: root: bitcoin: support Pluggable entrypoint
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// docker-finance | modern accounting for the power-user
|
||||
//
|
||||
// Copyright (C) 2025 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
// Copyright (C) 2025-2026 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -43,61 +43,74 @@ inline std::string get_repo_path()
|
||||
+ "/bitcoin/";
|
||||
}
|
||||
|
||||
//! \brief Initialize this bitcoin plugin
|
||||
//! \details Bare-essential initializations, will require manual loading for any further functionality
|
||||
//! \warning Initializations *MUST* occur here before any other bitcoin lib use
|
||||
//! \brief Pluggable entrypoint
|
||||
//! \ingroup cpp_plugin_impl
|
||||
//! \since docker-finance 1.1.0
|
||||
void load(const std::string& arg = {})
|
||||
class bitcoin_cc
|
||||
{
|
||||
namespace common = ::dfi::common;
|
||||
public:
|
||||
bitcoin_cc() = default;
|
||||
~bitcoin_cc() = default;
|
||||
|
||||
const std::string repo{get_repo_path()};
|
||||
bitcoin_cc(const bitcoin_cc&) = default;
|
||||
bitcoin_cc& operator=(const bitcoin_cc&) = default;
|
||||
|
||||
// Minimum requirements
|
||||
common::add_include_dir(repo + "src");
|
||||
common::add_linked_lib(repo + "build/lib/libbitcoinkernel.so");
|
||||
// WARNING: assertions *MUST* be enabled before loading any bitcoin headers
|
||||
common::line("#undef NDEBUG");
|
||||
common::load(repo + "src/kernel/bitcoinkernel_wrapper.h");
|
||||
bitcoin_cc(bitcoin_cc&&) = default;
|
||||
bitcoin_cc& operator=(bitcoin_cc&&) = default;
|
||||
|
||||
// `dfi`-specific requirements (API, macros, tests, etc.)
|
||||
common::line("#define __DFI_PLUGIN_BITCOIN__");
|
||||
common::load(repo + "src/random.h");
|
||||
// ...add as needed
|
||||
public:
|
||||
//! \brief Initialize this bitcoin plugin
|
||||
//! \details Bare-essential initializations, will require manual loading for any further functionality
|
||||
//! \warning Initializations *MUST* occur here before any other bitcoin lib use
|
||||
static void load(const std::string& arg = {})
|
||||
{
|
||||
namespace common = ::dfi::common;
|
||||
|
||||
if (!arg.empty())
|
||||
common::line(arg);
|
||||
}
|
||||
const std::string repo{get_repo_path()};
|
||||
|
||||
//! \brief Deinitialize this bitcoin plugin
|
||||
//! \details Bare-essential deinitializations, will require manual unloading for any other previously loaded functionality
|
||||
//! \warning Unloading certain bitcoin headers may result in Cling segfault due to bitcoin library design
|
||||
//! \ingroup cpp_plugin_impl
|
||||
//! \since docker-finance 1.1.0
|
||||
//! \todo It appears that, due to bitcoin design, unloading will result in
|
||||
//! Cling segfault "*** Break *** illegal instruction". With that said, it's
|
||||
//! best to exit `root` if you want a clean workspace (instead of unloading this plugin).
|
||||
void unload(const std::string& arg = {})
|
||||
{
|
||||
namespace common = ::dfi::common;
|
||||
// Minimum requirements
|
||||
common::add_include_dir(repo + "src");
|
||||
common::add_linked_lib(repo + "build/lib/libbitcoinkernel.so");
|
||||
// WARNING: assertions *MUST* be enabled before loading any bitcoin headers
|
||||
common::line("#undef NDEBUG");
|
||||
common::load(repo + "src/kernel/bitcoinkernel_wrapper.h");
|
||||
|
||||
if (!arg.empty())
|
||||
common::line(arg);
|
||||
// `dfi`-specific requirements (API, macros, tests, etc.)
|
||||
common::line("#define __DFI_PLUGIN_BITCOIN__");
|
||||
common::load(repo + "src/random.h");
|
||||
// ...add as needed
|
||||
|
||||
const std::string repo{get_repo_path()};
|
||||
if (!arg.empty())
|
||||
common::line(arg);
|
||||
}
|
||||
|
||||
// `dfi`-specific requirements (API, macros, tests, etc.)
|
||||
common::line("#undef __DFI_PLUGIN_BITCOIN__");
|
||||
common::unload(repo + "src/random.h");
|
||||
// ...add as needed
|
||||
//! \brief Deinitialize this bitcoin plugin
|
||||
//! \details Bare-essential deinitializations, will require manual unloading for any other previously loaded functionality
|
||||
//! \warning Unloading certain bitcoin headers may result in Cling segfault due to bitcoin library design
|
||||
//! \todo It appears that, due to bitcoin design, unloading will result in
|
||||
//! Cling segfault "*** Break *** illegal instruction". With that said, it's
|
||||
//! best to exit `root` if you want a clean workspace (instead of unloading this plugin).
|
||||
static void unload(const std::string& arg = {})
|
||||
{
|
||||
namespace common = ::dfi::common;
|
||||
|
||||
// Minimum requirements
|
||||
common::unload(repo + "src/kernel/bitcoinkernel_wrapper.h");
|
||||
common::line("#define NDEBUG");
|
||||
// TODO(unassigned): remove_include_dir()
|
||||
common::remove_linked_lib(repo + "build/lib/libbitcoinkernel.so");
|
||||
}
|
||||
if (!arg.empty())
|
||||
common::line(arg);
|
||||
|
||||
const std::string repo{get_repo_path()};
|
||||
|
||||
// `dfi`-specific requirements (API, macros, tests, etc.)
|
||||
common::line("#undef __DFI_PLUGIN_BITCOIN__");
|
||||
common::unload(repo + "src/random.h");
|
||||
// ...add as needed
|
||||
|
||||
// Minimum requirements
|
||||
common::unload(repo + "src/kernel/bitcoinkernel_wrapper.h");
|
||||
common::line("#define NDEBUG");
|
||||
// TODO(unassigned): remove_include_dir()
|
||||
common::remove_linked_lib(repo + "build/lib/libbitcoinkernel.so");
|
||||
}
|
||||
};
|
||||
} // namespace bitcoin
|
||||
} // namespace dfi::plugin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user