From 059c367d89aeab1f0320ac15d0d09802d652ed58 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 18 Nov 2022 21:04:05 +0100 Subject: [PATCH] multiple fixes over wallet and cmake --- CMakeLists.txt | 12 +++++++++--- contrib/epee/include/net/http_client.h | 2 +- src/CMakeLists.txt | 4 ++-- src/wallet/view_iface.h | 2 +- src/wallet/wallet2.cpp | 8 ++++---- src/wallet/wallet2.h | 2 +- src/wallet/wallet_rpc_server.cpp | 1 - 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db7b6613..6f2ee53a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,14 @@ PROJECT(Zano) set(VERSION "1.0") -# if(POLICY CMP0043) -# cmake_policy(SET CMP0043 OLD) -# endif() +if(POLICY CMP0043) + cmake_policy(SET CMP0043 NEW) +endif() +if(POLICY CMP0043) + cmake_policy(SET CMP0074 NEW) +endif() + + # if(POLICY CMP0020) # cmake_policy(SET CMP0020 OLD) @@ -50,6 +55,7 @@ message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built ty enable_testing() +find_package(OpenSSL REQUIRED) if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10.5) diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h index 846c5db8..b0c8838a 100644 --- a/contrib/epee/include/net/http_client.h +++ b/contrib/epee/include/net/http_client.h @@ -1072,7 +1072,7 @@ namespace epee return false; } - + inline bool fetch_url(const std::string& url, std::string& response_body, const std::string& method = "GET", const std::string& request_body = "", unsigned int timeout = 1000) { try diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c9178948..6b5ff732 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,7 +158,7 @@ add_dependencies(stratum version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(stratum STRATUM) -target_link_libraries(currency_core lmdb mdbx OpenSSL::SSL OpenSSL::Crypto) +target_link_libraries(currency_core lmdb mdbx) add_executable(daemon ${DAEMON} ${P2P} ${CURRENCY_PROTOCOL}) add_dependencies(daemon version) @@ -199,7 +199,7 @@ if(BUILD_GUI) QT5_USE_MODULES(Zano WebEngineWidgets WebChannel) find_package(Qt5PrintSupport REQUIRED) - target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) if (UNIX AND NOT APPLE) target_link_libraries(Zano rt) endif() diff --git a/src/wallet/view_iface.h b/src/wallet/view_iface.h index 5e5a8452..9a8a4e4d 100644 --- a/src/wallet/view_iface.h +++ b/src/wallet/view_iface.h @@ -215,7 +215,7 @@ public: struct wallet_info { - std::vector balances; + std::list balances; uint64_t mined_total; std::string address; std::string view_sec_key; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 1ea777f9..1513b251 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3125,13 +3125,13 @@ bool wallet2::balance(std::unordered_map& balances, uint64_t& mined) +bool wallet2::balance(std::list& balances, uint64_t& mined) const { std::unordered_map balances_map; this->balance(balances_map, mined); for (const auto& item : balances_map) { - asset_descriptor_base* asset_ptr = nullptr; + const asset_descriptor_base* asset_ptr = nullptr; //check if asset is whitelisted or customly added auto it = m_whitelisted_assets.find(item.first); if (it == m_whitelisted_assets.end()) @@ -3154,10 +3154,10 @@ bool wallet2::balance(std::vector& balances, balances.push_back(wallet_public::asset_balance_entry()); wallet_public::asset_balance_entry& new_item = balances.back(); - static_cast(new_item) = item.second; + static_cast(new_item) = item.second; new_item.asset_info.asset_id = item.first; CHECK_AND_ASSERT_THROW_MES(asset_ptr, "Internal error: asset_ptr i nullptr"); - static_cast(new_item.asset_info) = *asset_ptr; + static_cast(new_item.asset_info) = *asset_ptr; } return true; diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 58e47149..de0c60b5 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -566,7 +566,7 @@ namespace tools uint64_t balance() const; uint64_t balance(uint64_t& unloked, uint64_t& awaiting_in, uint64_t& awaiting_out, uint64_t& mined) const; bool balance(std::unordered_map& balances, uint64_t& mined) const; - bool balance(std::vector& balances, uint64_t& mined) const; + bool balance(std::list& balances, uint64_t& mined) const; uint64_t balance(uint64_t& unloked) const; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 2b4b86a1..e2c953a5 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -189,7 +189,6 @@ namespace tools // res.balance = m_wallet.balance(); // res.unlocked_balance = m_wallet.unlocked_balance(); uint64_t mined = 0; - // std::unordered_map balances; m_wallet.balance(res.balances, mined); for (auto it = res.balances.begin(); it != res.balances.end(); it++) {