diff --git a/README.md b/README.md index 84ce3ee..dca986b 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ The key features of the Onion Monero Blockchain Explorer are - the only explorer that can show which outputs belong to the given Monero address and viewkey, - the only explorer showing detailed information about mixins, such as, mixins' age, timescale, mixin of mixins, - - the only explorer correctly showing global output indices as well as thier amount indices. + - the only explorer showing amount output indices. ## Prerequisite diff --git a/main.cpp b/main.cpp index 6b498fa..11e6975 100644 --- a/main.cpp +++ b/main.cpp @@ -63,9 +63,39 @@ int main(int ac, const char* av[]) { return EXIT_FAILURE; } + // check if we have path to lmdb2 (i.e., custom db) + // and if it exists + + string custom_db_path_str; + + if (custom_db_path_opt) + { + if (boost::filesystem::exists(boost::filesystem::path(*custom_db_path_opt))) + { + custom_db_path_str = *custom_db_path_opt; + } + else + { + cerr << "Custom db path: " << *custom_db_path_opt + << "does not exist" << endl; + + return EXIT_FAILURE; + } + } + else + { + // if not given assume it is located in ~./bitmonero/lmdb2 folder + custom_db_path_str = blockchain_path.parent_path().string() + + string("/lmdb2"); + } + + custom_db_path_str = xmreg::remove_trailing_path_separator(custom_db_path_str); + + // create instance of page class which // contains logic for the website - xmreg::page xmrblocks(&mcore, core_storage, *deamon_url_opt); + xmreg::page xmrblocks(&mcore, core_storage, + *deamon_url_opt, custom_db_path_str); // crow instance crow::SimpleApp app; diff --git a/src/page.h b/src/page.h index 79d8453..242b79b 100644 --- a/src/page.h +++ b/src/page.h @@ -201,14 +201,18 @@ namespace xmreg { rpccalls rpc; time_t server_timestamp; + string lmdb2_path; + public: - page(MicroCore* _mcore, Blockchain* _core_storage, string deamon_url) + page(MicroCore* _mcore, Blockchain* _core_storage, + string _deamon_url, string _lmdb2_path) : mcore {_mcore}, core_storage {_core_storage}, - rpc {deamon_url}, - server_timestamp {std::time(nullptr)} + rpc {_deamon_url}, + server_timestamp {std::time(nullptr)}, + lmdb2_path {_lmdb2_path} { } @@ -1097,20 +1101,6 @@ namespace xmreg { cerr << e.what() << endl; } - // get global indices of outputs - vector out_global_indices; - - try - { - core_storage->get_tx_outputs_gindexs(txd.hash, - out_global_indices); - - } - catch(const exception& e) - { - cerr << e.what() << endl; - } - uint64_t output_idx {0}; mstch::array outputs; @@ -1122,16 +1112,6 @@ namespace xmreg { uint64_t num_outputs_amount = core_storage->get_db() .get_num_outputs(outp.second); - string out_global_index_str {"N/A"}; - - // outputs in tx in them mempool dont have yet global indices - // thus for them, we print N/A - if (!out_global_indices.empty()) - { - out_global_index_str = fmt::format("{:d}", - out_global_indices.at(output_idx)); - } - string out_amount_index_str {"N/A"}; // outputs in tx in them mempool dont have yet global indices @@ -1145,7 +1125,6 @@ namespace xmreg { outputs.push_back(mstch::map { {"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))}, {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(outp.second))}, - {"global_idx" , out_global_index_str}, {"amount_idx" , out_amount_index_str}, {"num_outputs" , fmt::format("{:d}", num_outputs_amount)}, {"output_idx" , fmt::format("{:02d}", output_idx++)} @@ -1467,8 +1446,8 @@ namespace xmreg { vector>> all_possible_tx_hashes; - //@TODO make lmdb2 path to some option - xmreg::MyLMDB mylmdb {"/home/mwo/.bitmonero/lmdb2"}; + + xmreg::MyLMDB mylmdb {lmdb2_path}; // search the custum lmdb for key_images and append the result // to those from the mempool search if found diff --git a/src/templates/tx.html b/src/templates/tx.html index 2575cab..81ded40 100644 --- a/src/templates/tx.html +++ b/src/templates/tx.html @@ -50,14 +50,12 @@ outputs public keys amount - global idx amount idx {{#outputs}} {{output_idx}}: {{out_pub_key}} {{amount}} - {{global_idx}} {{amount_idx}} of {{num_outputs}} {{/outputs}}