From b3d8279af345aa9b426ff40ffe88ed5ce4a713c5 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 25 Aug 2017 07:54:27 +0800 Subject: [PATCH] add changes from pr #76 https://github.com/moneroexamples/onion-monero-blockchain-explorer/pull/76/commits/4983786ed546002ccea81ae35afd496a2d698cb9 --- CMakeLists.txt | 10 ++++++++-- cmake/FindMonero.cmake | 6 ------ ext/mstch/include/mstch/mstch.hpp | 19 +++++++++++++++++-- src/page.h | 22 +++++++++++----------- src/tools.cpp | 2 +- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76d9e7f..d9db9f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ endif() if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32) add_library(unbound STATIC IMPORTED) - set_property(TARGET unbound PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libunbound.a) + set_property(TARGET unbound PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/unbound/libunbound.a) endif() # include boost headers @@ -113,9 +113,15 @@ set(LIBRARIES unbound curl crypto - atomic ssl) + +if(APPLE) + set(LIBRARIES ${LIBRARIES} "-framework IOKit") +else() + set(LIBRARIES ${LIBRARIES} atomic) +endif() + if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT WIN32) set(LIBRARIES ${LIBRARIES} unwind) endif() diff --git a/cmake/FindMonero.cmake b/cmake/FindMonero.cmake index 8ada571..89a2ee7 100644 --- a/cmake/FindMonero.cmake +++ b/cmake/FindMonero.cmake @@ -57,12 +57,6 @@ foreach (l ${LIBS}) endforeach() - -if (EXISTS ${MONERO_BUILD_DIR}/external/unbound/libunbound.a) - add_library(unbound STATIC IMPORTED) - set_property(TARGET unbound PROPERTY IMPORTED_LOCATION ${MONERO_BUILD_DIR}/external/unbound/libunbound.a) -endif() - if (EXISTS ${MONERO_BUILD_DIR}/external/easylogging++/libeasylogging.a) add_library(easylogging STATIC IMPORTED) set_property(TARGET easylogging diff --git a/ext/mstch/include/mstch/mstch.hpp b/ext/mstch/include/mstch/mstch.hpp index 2427b38..4052bbd 100644 --- a/ext/mstch/include/mstch/mstch.hpp +++ b/ext/mstch/include/mstch/mstch.hpp @@ -91,17 +91,32 @@ class lambda_t { std::function renderer, const std::string&)> fun; }; +template +struct map : public std::map +{ + map() {} + map(const map& rhs) : std::map(rhs) {} + map(const std::initializer_list::value_type>& args) : std::map(args) {} + map& operator=(const map& rhs) + { + std::map::clear(); + for (auto& i : rhs) + std::map::insert(i); + return *this; + } +}; + } using node = boost::make_recursive_variant< std::nullptr_t, std::string, int, double, bool, uint64_t, int64_t, uint32_t, internal::lambda_t, std::shared_ptr>, - std::map, + internal::map, std::vector>::type; using object = internal::object_t; using lambda = internal::lambda_t; -using map = std::map; +using map = internal::map; using array = std::vector; std::string render( diff --git a/src/page.h b/src/page.h index 36ae0f5..45a604f 100644 --- a/src/page.h +++ b/src/page.h @@ -182,7 +182,7 @@ namespace xmreg {"no_nonrct_inputs" , num_nonrct_inputs}, {"mixin" , mixin_str}, {"blk_height" , blk_height}, - {"version" , version}, + {"version" , static_cast(version)}, {"has_payment_id" , payment_id != null_hash}, {"has_payment_id8" , payment_id8 != null_hash8}, {"payment_id" , pod_to_hex(payment_id)}, @@ -824,7 +824,7 @@ namespace xmreg // initalise page tempate map with basic info about mempool mstch::map context { - {"mempool_size" , total_no_of_mempool_tx}, // total no of mempool txs + {"mempool_size" , static_cast(total_no_of_mempool_tx)}, // total no of mempool txs {"show_cache_times" , show_cache_times}, {"mempool_refresh_time" , MempoolStatus::mempool_refresh_time} }; @@ -1238,7 +1238,7 @@ namespace xmreg mstch::map tx_context; - if (enable_tx_cache && tx_context_cache.Contains({tx_hash, with_ring_signatures})) + if (enable_tx_cache && tx_context_cache.Contains({tx_hash, static_cast(with_ring_signatures)})) { // with_ring_signatures == 0 means that cache is not used // when obtaining detailed information about tx is requested. @@ -1248,7 +1248,7 @@ namespace xmreg auto start = std::chrono::steady_clock::now(); const tx_info_cache& tx_info_cashed - = tx_context_cache.Get({tx_hash, with_ring_signatures}); + = tx_context_cache.Get({tx_hash, static_cast(with_ring_signatures)}); tx_context = tx_info_cashed.tx_map; @@ -1302,10 +1302,10 @@ namespace xmreg // its not in blockchain, but it was there when we cashed it. // so we update it in cash, as it should be back in mempool - tx_context = construct_tx_context(tx, with_ring_signatures); + tx_context = construct_tx_context(tx, static_cast(with_ring_signatures)); tx_context_cache.Put( - {tx_hash, with_ring_signatures}, + {tx_hash, static_cast(with_ring_signatures)}, tx_info_cache { boost::get(tx_context["tx_blk_height"]), boost::get(tx_context["blk_timestamp_uint"]), @@ -1324,10 +1324,10 @@ namespace xmreg // checking if in blockchain already // it was before in mempool, but now maybe already in blockchain - tx_context = construct_tx_context(tx, with_ring_signatures); + tx_context = construct_tx_context(tx, static_cast(with_ring_signatures)); tx_context_cache.Put( - {tx_hash, with_ring_signatures}, + {tx_hash, static_cast(with_ring_signatures)}, tx_info_cache { boost::get(tx_context["tx_blk_height"]), boost::get(tx_context["blk_timestamp_uint"]), @@ -1361,7 +1361,7 @@ namespace xmreg // tx context. just for fun, to see if cache is any faster. auto start = std::chrono::steady_clock::now(); - tx_context = construct_tx_context(tx, with_ring_signatures); + tx_context = construct_tx_context(tx, static_cast(with_ring_signatures)); auto duration = std::chrono::duration_cast (std::chrono::steady_clock::now() - start); @@ -1369,7 +1369,7 @@ namespace xmreg if (enable_tx_cache) { tx_context_cache.Put( - {tx_hash, with_ring_signatures}, + {tx_hash, static_cast(with_ring_signatures)}, tx_info_cache { boost::get(tx_context["tx_blk_height"]), boost::get(tx_context["blk_timestamp_uint"]), @@ -5124,7 +5124,7 @@ namespace xmreg {"tx_size" , txd.size}, {"xmr_outputs" , txd.xmr_outputs}, {"xmr_inputs" , txd.xmr_inputs}, - {"tx_version" , txd.version}, + {"tx_version" , static_cast(txd.version)}, {"rct_type" , tx.rct_signatures.type}, {"coinbase" , is_coinbase(tx)}, {"mixin" , txd.mixin_no}, diff --git a/src/tools.cpp b/src/tools.cpp index 992ce75..bf16c09 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -4,7 +4,7 @@ #include "tools.h" #include - +#include namespace xmreg {