indices added to tx info

This commit is contained in:
moneroexamples 2016-04-22 01:54:16 +00:00
parent dd57af6158
commit 3a7174541e
2 changed files with 32 additions and 22 deletions

View file

@ -573,7 +573,9 @@ namespace xmreg {
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"tx_hash" , tx_hash_str},
{"blk_height" , _blk_height}
{"blk_height" , _blk_height},
{"inputs_no" , txd.input_key_imgs.size()},
{"outputs_no" , txd.output_pub_keys.size()}
};
string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F");
@ -584,6 +586,9 @@ namespace xmreg {
mstch::array mixins_timescales;
double timescale_scale {0.0}; // size of one '_' in days
uint64_t input_idx {0};
// make timescale maps for mixins in input
for (const txin_to_key& in_key: txd.input_key_imgs)
{
@ -600,19 +605,21 @@ namespace xmreg {
vector<uint64_t> mixin_timestamps;
size_t count = 0;
inputs.push_back(mstch::map {
{"in_key_img", REMOVE_HASH_BRAKETS(fmt::format("{:s}", in_key.k_image))},
{"amount" , fmt::format("{:0.3f}", XMR_AMOUNT(in_key.amount))},
{"mixins" , mstch::array{}}
{"amount" , fmt::format("{:0.8f}", XMR_AMOUNT(in_key.amount))},
{"input_idx" , fmt::format("{:02d}", input_idx++)},
{"mixins" , mstch::array{}},
});
// get reference to mixins array created above
mstch::array& mixins = boost::get<mstch::array>(
boost::get<mstch::map>(inputs.back())["mixins"]);
size_t count = 0;
// for each found output public key find its block to get timestamp
for (const uint64_t &i: absolute_offsets)
{
@ -642,7 +649,8 @@ namespace xmreg {
{"mix_out_indx" , fmt::format("{:d}", tx_out_idx.second)},
{"mix_timestamp" , xmreg::timestamp_to_str(blk.timestamp)},
{"mix_age" , mixin_age.first},
{"mix_age_format" , mixin_age.second}
{"mix_age_format" , mixin_age.second},
{"mix_idx" , fmt::format("{:02d}", count)},
});
// get mixin timestamp from its orginal block
@ -670,13 +678,17 @@ namespace xmreg {
context["timescales_scale"] = fmt::format("{:0.2f}",
timescale_scale / 3600.0 / 24.0); // in days
uint64_t output_idx {0};
mstch::array outputs;
for (pair<txout_to_key, uint64_t>& outp: txd.output_pub_keys)
{
outputs.push_back(mstch::map {
{"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))},
{"amount" , fmt::format("{:0.4f}", XMR_AMOUNT(outp.second))}
{"amount" , fmt::format("{:0.8f}", XMR_AMOUNT(outp.second))},
{"output_idx" , fmt::format("{:02d}", output_idx++)}
});
}

View file

@ -33,7 +33,7 @@
</table>
<h3>Outputs</h3>
<h3>Outputs ({{outputs_no}})</h3>
<div class="center">
<table class="center" >
<tr>
@ -42,7 +42,7 @@
</tr>
{{#outputs}}
<tr>
<td>{{out_pub_key}}</td>
<td>{{output_idx}}: {{out_pub_key}}</td>
<td>{{amount}}</td>
</tr>
{{/outputs}}
@ -61,31 +61,29 @@
</div>
<h3>Inputs {{inputs_no}}</h3>
<h3>Inputs ({{inputs_no}})</h3>
<div class="center">
<table class="center">
<tr>
<td>key image</td>
<td>amount</td>
</tr>
{{#inputs}}
<tr>
<td>{{in_key_img}}</td>
<td>{{amount}}</td>
<td style="text-align: left;">key image {{input_idx}}: {{in_key_img}}</td>
<td>amount: {{amount}}</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%">
<table style="width:100%; margin-bottom:20px">
<tr>
<td>pub_key</td>
<td>Mixin public key</td>
<td>blk</td>
<td>timestamp</td>
<td>age</td>
</tr>
{{#mixins}}
<tr>
<td><a href="/tx/{{mix_tx_hash}}">{{mix_pub_key}}</a></td> <td>{{mix_blk}}</td> <td>{{mix_timestamp}}</td><td>{{mix_age}}</td>
<td> - {{mix_idx}}: <a href="/tx/{{mix_tx_hash}}">{{mix_pub_key}}</a></td>
<td>{{mix_blk}}</td>
<td>{{mix_timestamp}}</td>
<td>{{mix_age}}</td>
</tr>
<!-- <tr>
<td>{{mix_tx_hash}}</td> <td>{{mix_out_indx}}</td><td></td><td></td>