From 271addafac6d05595959108f6573c65592c1d867 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sat, 16 Mar 2019 12:02:44 +0800 Subject: [PATCH] make it work with master and release-v0.13 branches --- .gitignore | 1 + README.md | 6 +-- src/page.h | 136 ++++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 119 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 832ca90..9a098af 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ tests/ build/ cmake-build-debug/ +.ycm_extra_conf.py diff --git a/README.md b/README.md index 0bd0e40..8d4110c 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Note: `devel` branch of the explorer follows `master` branch of the monero. ## Compilation on Ubuntu 16.04/18.04 -##### Compile latest Monero version (0.14.0.0) +##### Compile latest Monero version (0.14.0.2) Download and compile recent Monero into your home folder: @@ -106,8 +106,8 @@ sudo apt install git build-essential cmake libboost-all-dev miniupnpc libunbound # go to home folder cd ~ -# download monero sourced for branch release-v0.13 -git clone --recursive -b release-v0.13 https://github.com/monero-project/monero.git +# download monero sourced for master branch +git clone --recursive https://github.com/monero-project/monero.git cd monero/ diff --git a/src/page.h b/src/page.h index 42115ca..3f7d3d7 100644 --- a/src/page.h +++ b/src/page.h @@ -35,7 +35,7 @@ #include #include #include - +#include #define TMPL_DIR "./templates" @@ -103,6 +103,43 @@ struct tx_info_cache }; }; + +// helper to ignore any number of template parametrs +template using VoidT = void; + +// primary template; +template> +struct HasSpanInGetOutputKeyT: std::false_type +{}; + +//partial specialization (myy be SFINAEed away) +template +struct HasSpanInGetOutputKeyT< + T, + VoidT() + .get_output_key( + std::declval&>(), + std::declval&>(), + std::declval&>())) + >>: std::true_type +{}; + + +// primary template; +template> +struct OutputIndicesReturnVectOfVectT : std::false_type +{}; + +template +struct OutputIndicesReturnVectOfVectT< + T, + VoidT() + .get_tx_amount_output_indices( + uint64_t{}, size_t{}) + .front().front()) + >>: std::true_type +{}; + // indect overload of hash for tx_info_cache::key namespace std { @@ -466,7 +503,6 @@ page(MicroCore* _mcore, testnet = nettype == cryptonote::network_type::TESTNET; stagenet = nettype == cryptonote::network_type::STAGENET; - no_of_mempool_tx_of_frontpage = 25; // read template files for all the pages @@ -1720,9 +1756,12 @@ show_ringmembers_hex(string const& tx_hash_str) == false) continue; - core_storage->get_db().get_output_key(in_key.amount, - absolute_offsets, - mixin_outputs); + //core_storage->get_db().get_output_key(in_key.amount, + // absolute_offsets, + // mixin_outputs); + get_output_key(in_key.amount, + absolute_offsets, + mixin_outputs); } catch (OUTPUT_DNE const& e) { @@ -2008,10 +2047,14 @@ show_ringmemberstx_jsonhex(string const& tx_hash_str) in_key.amount, absolute_offsets, indices); // get mining ouput info - core_storage->get_db().get_output_key( - in_key.amount, - absolute_offsets, - mixin_outputs); + //core_storage->get_db().get_output_key( + //in_key.amount, + //absolute_offsets, + //mixin_outputs); + + get_output_key(in_key.amount, + absolute_offsets, + mixin_outputs); } catch (exception const& e) { @@ -2524,9 +2567,13 @@ show_my_outputs(string tx_hash_str, if (are_absolute_offsets_good(absolute_offsets, in_key) == false) continue; - core_storage->get_db().get_output_key(in_key.amount, - absolute_offsets, - mixin_outputs); + //core_storage->get_db().get_output_key(in_key.amount, + //absolute_offsets, + //mixin_outputs); + + get_output_key(in_key.amount, + absolute_offsets, + mixin_outputs); } catch (const OUTPUT_DNE& e) { @@ -4687,9 +4734,13 @@ json_transaction(string tx_hash_str) if (are_absolute_offsets_good(absolute_offsets, in_key) == false) continue; - core_storage->get_db().get_output_key(in_key.amount, - absolute_offsets, - outputs); + //core_storage->get_db().get_output_key(in_key.amount, + //absolute_offsets, + //outputs); + + get_output_key(in_key.amount, + absolute_offsets, + outputs); } catch (const OUTPUT_DNE &e) { @@ -6363,9 +6414,13 @@ construct_tx_context(transaction tx, uint16_t with_ring_signatures = 0) // offsets seems good, so try to get the outputs for the amount and // offsets given - core_storage->get_db().get_output_key(in_key.amount, - absolute_offsets, - outputs); + //core_storage->get_db().get_output_key(in_key.amount, + //absolute_offsets, + //outputs); + + get_output_key(in_key.amount, + absolute_offsets, + outputs); } catch (const std::exception& e) { @@ -6575,8 +6630,11 @@ construct_tx_context(transaction tx, uint16_t with_ring_signatures = 0) if (core_storage->get_db().tx_exists(txd.hash, tx_index)) { - out_amount_indices = core_storage->get_db() - .get_tx_amount_output_indices(tx_index); + //out_amount_indices = core_storage->get_db() + //.get_tx_amount_output_indices(tx_index).front(); + get_tx_amount_output_indices( + out_amount_indices, + tx_index); } else { @@ -7080,9 +7138,45 @@ add_js_files(mstch::map& context) }}; } +template +typename std::enable_if< + HasSpanInGetOutputKeyT::value, void>::type +get_output_key(uint64_t amount, Args&&... args) +{ + core_storage->get_db().get_output_key( + epee::span(&amount, 1), + std::forward(args)...); +} + +template +typename std::enable_if< + !HasSpanInGetOutputKeyT::value, void>::type +get_output_key(uint64_t amount, Args&&... args) +{ + core_storage->get_db().get_output_key( + amount, std::forward(args)...); +} + +template +typename std::enable_if< + !OutputIndicesReturnVectOfVectT::value, void>::type +get_tx_amount_output_indices(vector& out_amount_indices, Args&&... args) +{ + out_amount_indices = core_storage->get_db() + .get_tx_amount_output_indices(std::forward(args)...); +} + +template +typename std::enable_if< + OutputIndicesReturnVectOfVectT::value, void>::type +get_tx_amount_output_indices(vector& out_amount_indices, Args&&... args) +{ + out_amount_indices = core_storage->get_db() + .get_tx_amount_output_indices(std::forward(args)...).front(); +} + }; } - #endif //CROWXMR_PAGE_H