From abd1d47aa3f5fc4fed4c7993ccaef61b53b26b0b Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 11 Feb 2020 17:13:03 +0100 Subject: [PATCH] check for wrong initialization code on app level --- src/wallet/plain_wallet_api.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 6291aef2..2790692d 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -10,11 +10,7 @@ #include "currency_core/currency_format_utils.h" #include "wallets_manager.h" -//TODO: global objects, need refactoring. Just temporary solution -// std::map ginstances; -// epee::critical_section ginstances_lock; -// std::atomic gcounter(1); -// std::atomic glogs_initialized(false); +std::atomic initialized(false); #define HOME_FOLDER "Documents" #define WALLETS_FOLDER_NAME "wallets" @@ -56,6 +52,13 @@ namespace plain_wallet std::string init(const std::string& ip, const std::string& port) { + if (initialized) + { + LOG_ERROR("Double-initialization in plain_wallet detected."); + throw std::runtime_error("Double-initialization in plain_wallet detected."); + } + + initialize_logs(); std::string argss_1 = std::string("--remote-nodes=") + ip + ":" + port; char * args[] = {"", 0};