make it work with master and release-v0.13 branches

This commit is contained in:
moneroexamples 2019-03-16 12:02:44 +08:00
parent 73ed903eff
commit 271addafac
3 changed files with 119 additions and 24 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@
tests/ tests/
build/ build/
cmake-build-debug/ cmake-build-debug/
.ycm_extra_conf.py

View File

@ -93,7 +93,7 @@ Note: `devel` branch of the explorer follows `master` branch of the monero.
## Compilation on Ubuntu 16.04/18.04 ## 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: 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 # go to home folder
cd ~ cd ~
# download monero sourced for branch release-v0.13 # download monero sourced for master branch
git clone --recursive -b release-v0.13 https://github.com/monero-project/monero.git git clone --recursive https://github.com/monero-project/monero.git
cd monero/ cd monero/

View File

@ -35,7 +35,7 @@
#include <limits> #include <limits>
#include <ctime> #include <ctime>
#include <future> #include <future>
#include <type_traits>
#define TMPL_DIR "./templates" #define TMPL_DIR "./templates"
@ -103,6 +103,43 @@ struct tx_info_cache
}; };
}; };
// helper to ignore any number of template parametrs
template<typename...> using VoidT = void;
// primary template;
template<typename, typename = VoidT<>>
struct HasSpanInGetOutputKeyT: std::false_type
{};
//partial specialization (myy be SFINAEed away)
template <typename T>
struct HasSpanInGetOutputKeyT<
T,
VoidT<decltype(std::declval<T>()
.get_output_key(
std::declval<const epee::span<const uint64_t>&>(),
std::declval<const std::vector<uint64_t>&>(),
std::declval<std::vector<cryptonote::output_data_t>&>()))
>>: std::true_type
{};
// primary template;
template<typename, typename = VoidT<>>
struct OutputIndicesReturnVectOfVectT : std::false_type
{};
template<typename T>
struct OutputIndicesReturnVectOfVectT<
T,
VoidT<decltype(std::declval<T>()
.get_tx_amount_output_indices(
uint64_t{}, size_t{})
.front().front())
>>: std::true_type
{};
// indect overload of hash for tx_info_cache::key // indect overload of hash for tx_info_cache::key
namespace std namespace std
{ {
@ -466,7 +503,6 @@ page(MicroCore* _mcore,
testnet = nettype == cryptonote::network_type::TESTNET; testnet = nettype == cryptonote::network_type::TESTNET;
stagenet = nettype == cryptonote::network_type::STAGENET; stagenet = nettype == cryptonote::network_type::STAGENET;
no_of_mempool_tx_of_frontpage = 25; no_of_mempool_tx_of_frontpage = 25;
// read template files for all the pages // read template files for all the pages
@ -1720,9 +1756,12 @@ show_ringmembers_hex(string const& tx_hash_str)
== false) == false)
continue; continue;
core_storage->get_db().get_output_key(in_key.amount, //core_storage->get_db().get_output_key(in_key.amount,
absolute_offsets, // absolute_offsets,
mixin_outputs); // mixin_outputs);
get_output_key<BlockchainDB>(in_key.amount,
absolute_offsets,
mixin_outputs);
} }
catch (OUTPUT_DNE const& e) catch (OUTPUT_DNE const& e)
{ {
@ -2008,10 +2047,14 @@ show_ringmemberstx_jsonhex(string const& tx_hash_str)
in_key.amount, absolute_offsets, indices); in_key.amount, absolute_offsets, indices);
// get mining ouput info // get mining ouput info
core_storage->get_db().get_output_key( //core_storage->get_db().get_output_key(
in_key.amount, //in_key.amount,
absolute_offsets, //absolute_offsets,
mixin_outputs); //mixin_outputs);
get_output_key<BlockchainDB>(in_key.amount,
absolute_offsets,
mixin_outputs);
} }
catch (exception const& e) 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) if (are_absolute_offsets_good(absolute_offsets, in_key) == false)
continue; continue;
core_storage->get_db().get_output_key(in_key.amount, //core_storage->get_db().get_output_key(in_key.amount,
absolute_offsets, //absolute_offsets,
mixin_outputs); //mixin_outputs);
get_output_key<BlockchainDB>(in_key.amount,
absolute_offsets,
mixin_outputs);
} }
catch (const OUTPUT_DNE& e) 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) if (are_absolute_offsets_good(absolute_offsets, in_key) == false)
continue; continue;
core_storage->get_db().get_output_key(in_key.amount, //core_storage->get_db().get_output_key(in_key.amount,
absolute_offsets, //absolute_offsets,
outputs); //outputs);
get_output_key<BlockchainDB>(in_key.amount,
absolute_offsets,
outputs);
} }
catch (const OUTPUT_DNE &e) 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 seems good, so try to get the outputs for the amount and
// offsets given // offsets given
core_storage->get_db().get_output_key(in_key.amount, //core_storage->get_db().get_output_key(in_key.amount,
absolute_offsets, //absolute_offsets,
outputs); //outputs);
get_output_key<BlockchainDB>(in_key.amount,
absolute_offsets,
outputs);
} }
catch (const std::exception& e) 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)) if (core_storage->get_db().tx_exists(txd.hash, tx_index))
{ {
out_amount_indices = core_storage->get_db() //out_amount_indices = core_storage->get_db()
.get_tx_amount_output_indices(tx_index); //.get_tx_amount_output_indices(tx_index).front();
get_tx_amount_output_indices<BlockchainDB>(
out_amount_indices,
tx_index);
} }
else else
{ {
@ -7080,9 +7138,45 @@ add_js_files(mstch::map& context)
}}; }};
} }
template <typename T, typename... Args>
typename std::enable_if<
HasSpanInGetOutputKeyT<T>::value, void>::type
get_output_key(uint64_t amount, Args&&... args)
{
core_storage->get_db().get_output_key(
epee::span<const uint64_t>(&amount, 1),
std::forward<Args>(args)...);
}
template <typename T, typename... Args>
typename std::enable_if<
!HasSpanInGetOutputKeyT<T>::value, void>::type
get_output_key(uint64_t amount, Args&&... args)
{
core_storage->get_db().get_output_key(
amount, std::forward<Args>(args)...);
}
template <typename T, typename... Args>
typename std::enable_if<
!OutputIndicesReturnVectOfVectT<T>::value, void>::type
get_tx_amount_output_indices(vector<uint64_t>& out_amount_indices, Args&&... args)
{
out_amount_indices = core_storage->get_db()
.get_tx_amount_output_indices(std::forward<Args>(args)...);
}
template <typename T, typename... Args>
typename std::enable_if<
OutputIndicesReturnVectOfVectT<T>::value, void>::type
get_tx_amount_output_indices(vector<uint64_t>& out_amount_indices, Args&&... args)
{
out_amount_indices = core_storage->get_db()
.get_tx_amount_output_indices(std::forward<Args>(args)...).front();
}
}; };
} }
#endif //CROWXMR_PAGE_H #endif //CROWXMR_PAGE_H