From a2d3f426994a5a6621c5fc61c49ea28e2c90eef5 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 10 May 2016 00:31:51 +0000 Subject: [PATCH] dont show outputs global indices for tx in mempool --- src/page.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/page.h b/src/page.h index 984130c..0582683 100644 --- a/src/page.h +++ b/src/page.h @@ -1072,8 +1072,18 @@ namespace xmreg { timescale_scale / 3600.0 / 24.0); // in days // get outputs global indices - vector out_global_indices = - core_storage->get_db().get_tx_amount_output_indices(txd.hash); + vector out_global_indices; + + try + { + out_global_indices = core_storage->get_db() + .get_tx_amount_output_indices(txd.hash); + } + catch(const exception& e) + { + cerr << e.what() << endl; + } + uint64_t output_idx {0}; @@ -1086,10 +1096,20 @@ 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)); + } + 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" , fmt::format("{:d}", out_global_indices.at(output_idx))}, + {"global_idx" , out_global_index_str}, {"num_outputs" , fmt::format("{:d}", num_outputs_amount)}, {"output_idx" , fmt::format("{:02d}", output_idx++)} });