global output indices removed

This commit is contained in:
moneroexamples 2016-05-22 12:25:39 +08:00
parent 173970bdeb
commit 7c4e0f3044
4 changed files with 41 additions and 34 deletions

View File

@ -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

View File

@ -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;

View File

@ -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<uint64_t> 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<pair<string, vector<string>>> 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

View File

@ -50,14 +50,12 @@
<tr>
<td>outputs public keys</td>
<td>amount</td>
<td>global idx</td>
<td>amount idx</td>
</tr>
{{#outputs}}
<tr>
<td>{{output_idx}}: {{out_pub_key}}</td>
<td>{{amount}}</td>
<td>{{global_idx}}</td>
<td>{{amount_idx}} of {{num_outputs}}</td>
</tr>
{{/outputs}}