Merge pull request #2 from logos-blockchain/fix/qt-declarations

fix: Runtime issues after restructure
This commit is contained in:
Álex 2026-02-02 17:40:20 +01:00 committed by GitHub
commit 7b2c4c1289
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 54 additions and 31 deletions

View File

@ -162,13 +162,12 @@ set_target_properties(${PLUGIN_TARGET} PROPERTIES
)
target_sources(${PLUGIN_TARGET} PRIVATE
src/logos_blockchain_module.cpp
src/logos_blockchain_module.h
metadata.json
${CMAKE_CURRENT_SOURCE_DIR}/src/logos_blockchain_module.cpp
${CMAKE_CURRENT_SOURCE_DIR}/metadata.json
)
set_target_properties(${PLUGIN_TARGET} PROPERTIES
PUBLIC_HEADER "src/i_logos_blockchain_module.h"
set_property(TARGET ${PLUGIN_TARGET} PROPERTY PUBLIC_HEADER
${CMAKE_CURRENT_SOURCE_DIR}/src/i_logos_blockchain_module.h
)
target_include_directories(${PLUGIN_TARGET} PRIVATE

View File

@ -190,6 +190,11 @@ storage:
mempool:
recovery_path: ./resources/recovery/mempool.json
sdp:
declaration: null
wallet_config:
max_tx_fee: 18446744073709551615 # u64::MAX
# SDP funding public key - matches the genesis note pk used for SDP transaction fees
funding_pk: "89b7314f5184bae9eb7fa511098eb321b97b8fbbdec611dda591e0c01e18331d"
wallet:
known_keys:
- "0000000000000000000000000000000000000000000000000000000000000000"

View File

@ -94,10 +94,9 @@
pkgs = mkPkgs system;
logosBlockchainModule = self.packages.${system}.logos-blockchain-module;
logosModuleViewer = logos-module-viewer.packages.${system}.default;
extension =
if pkgs.stdenv.isDarwin then "dylib"
else if pkgs.stdenv.isWindows then "dll"
else "so";
extension = if pkgs.stdenv.isDarwin then "dylib"
else if pkgs.stdenv.hostPlatform.isWindows then "dll"
else "so";
in
{
default = {

View File

@ -11,25 +11,19 @@ extern "C" {
}
#endif
class ILogosBlockchainModule : public QObject, public PluginInterface {
Q_INTERFACES(PluginInterface)
class ILogosBlockchainModule {
public:
using QObject::QObject;
~ILogosBlockchainModule() override = default;
virtual ~ILogosBlockchainModule() = default;
// Logos Core
Q_INVOKABLE virtual void initLogos(LogosAPI* logosAPIInstance) = 0;
virtual void initLogos(LogosAPI* logosAPIInstance) = 0;
// Node
Q_INVOKABLE virtual int start(const QString& config_path) = 0;
Q_INVOKABLE virtual int stop() = 0;
Q_INVOKABLE virtual int subscribe() = 0;
Q_INVOKABLE virtual int wallet_get_balance(const uint8_t* wallet_address, const HeaderId* optional_tip, BalanceResult* output_balance) = 0;
Q_INVOKABLE virtual int wallet_transfer_funds(const TransferFundsArguments* transfer_funds_arguments, Hash* output_hash) = 0;
signals:
void eventResponse(const QString& eventName, const QVariantList& data);
virtual int start(const QString& config_path, const QString& deployment) = 0;
virtual int stop() = 0;
virtual int subscribe() = 0;
virtual int wallet_get_balance(const uint8_t* wallet_address, const HeaderId* optional_tip, BalanceResult* output_balance) = 0;
virtual int wallet_transfer_funds(const TransferFundsArguments* transfer_funds_arguments, Hash* output_hash) = 0;
};
#define ILogosBlockchainModule_iid "org.logos.ilogosblockchainmodule"

View File

@ -23,19 +23,39 @@ void LogosBlockchainModule::initLogos(LogosAPI* logosAPIInstance) {
logosAPI = logosAPIInstance;
}
int LogosBlockchainModule::start(const QString& config_path) {
int LogosBlockchainModule::start(const QString& config_path, const QString& deployment) {
if (node) {
qWarning() << "Could not execute the operation: The node is already running.";
return 1;
}
const QByteArray path = config_path.toUtf8();
const char* deployment = nullptr;
QString effective_config_path= config_path;
auto [value, error] = start_lb_node(path.constData(), deployment);
if (effective_config_path.isEmpty()) {
const char* env = std::getenv("LB_CONFIG_PATH");
if (env && *env) {
effective_config_path = QString::fromUtf8(env);
qInfo() << "Using config from LB_CONFIG_PATH:" << effective_config_path;
} else {
qCritical() << "Config path was not specified and LB_CONFIG_PATH is not set.";
return 2;
}
}
qInfo() << "Starting the node with the configuration file:" << effective_config_path;
qInfo() << "Using deployment:" << (deployment.isEmpty() ? "<default>" : deployment);
const QByteArray config_path_buffer = effective_config_path.toUtf8();
const char* config_path_ptr = effective_config_path.isEmpty() ? nullptr : config_path_buffer.constData();
const QByteArray deployment_buffer = deployment.toUtf8();
const char* deployment_ptr = deployment.isEmpty() ? nullptr : deployment_buffer.constData();
auto [value, error] = start_lb_node(config_path_ptr, deployment_ptr);
qInfo() << "Start node returned with value and error.";
if (!is_ok(&error)) {
qCritical() << "Failed to start the node. Error:" << error;
return 2;
return 3;
}
node = value;

View File

@ -2,24 +2,30 @@
#include "i_logos_blockchain_module.h"
class LogosBlockchainModule final : public ILogosBlockchainModule {
class LogosBlockchainModule final : public QObject, public PluginInterface, public ILogosBlockchainModule {
Q_OBJECT
Q_PLUGIN_METADATA(IID ILogosBlockchainModule_iid FILE "../metadata.json")
Q_INTERFACES(PluginInterface)
public:
LogosBlockchainModule();
~LogosBlockchainModule() override;
// Logos Core
[[nodiscard]] QString name() const override;
[[nodiscard]] QString version() const override;
Q_INVOKABLE void initLogos(LogosAPI*) override;
Q_INVOKABLE int start(const QString&) override;
// Logos Blockchain
Q_INVOKABLE int start(const QString& config_path, const QString& deployment) override;
Q_INVOKABLE int stop() override;
Q_INVOKABLE int subscribe() override;
Q_INVOKABLE int wallet_get_balance(const uint8_t*, const HeaderId*, BalanceResult*) override;
Q_INVOKABLE int wallet_transfer_funds(const TransferFundsArguments*, Hash*) override;
signals:
void eventResponse(const QString& eventName, const QVariantList& data);
private:
LogosBlockchainNode* node = nullptr;
};