blk info for mixins started

master
moneroexamples 9 years ago
parent a6c2105b85
commit 178447f8e7

@ -570,25 +570,47 @@ namespace xmreg {
tx_details txd = get_tx_details(tx); tx_details txd = get_tx_details(tx);
uint64_t _blk_height {0}; uint64_t tx_blk_height {0};
bool tx_blk_found {false};
try
{
tx_blk_height = core_storage->get_db().get_tx_block_height(tx_hash);
tx_blk_found = true;
}
catch (BLOCK_DNE & e)
{
cerr << "Cant get block height: " << tx_hash << endl;
}
// get block cointaining this tx
block blk;
if (!mcore->get_block_by_height(tx_blk_height, blk))
{
cerr << "Cant get block: " << tx_blk_height << endl;
}
cout << "tx_blk_height: " << tx_blk_height << endl;
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"tx_hash" , tx_hash_str}, {"tx_hash" , tx_hash_str},
{"blk_height" , _blk_height}, {"blk_height" , tx_blk_height},
{"inputs_no" , txd.input_key_imgs.size()}, {"inputs_no" , txd.input_key_imgs.size()},
{"outputs_no" , txd.output_pub_keys.size()} {"outputs_no" , txd.output_pub_keys.size()}
}; };
string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F"); string server_time_str = xmreg::timestamp_to_str(server_timestamp,
"%F");
mstch::array inputs = mstch::array{}; mstch::array inputs = mstch::array{};
mstch::array mixins_timescales; mstch::array mixins_timescales;
double timescale_scale {0.0}; // size of one '_' in days double timescale_scale {0.0}; // size of one '_' in days
uint64_t input_idx {0}; uint64_t input_idx {0};
// make timescale maps for mixins in input // make timescale maps for mixins in input
@ -607,8 +629,6 @@ namespace xmreg {
vector<uint64_t> mixin_timestamps; vector<uint64_t> mixin_timestamps;
inputs.push_back(mstch::map { inputs.push_back(mstch::map {
{"in_key_img", REMOVE_HASH_BRAKETS(fmt::format("{:s}", in_key.k_image))}, {"in_key_img", REMOVE_HASH_BRAKETS(fmt::format("{:s}", in_key.k_image))},
{"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))}, {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))},
@ -639,20 +659,37 @@ namespace xmreg {
if (!mcore->get_block_by_height(output_data.height, blk)) if (!mcore->get_block_by_height(output_data.height, blk))
{ {
cerr << "- cant get block of height: " << output_data.height << endl; cerr << "- cant get block of height: " << output_data.height << endl;
return fmt::format("- cant get block of height: {}\n", output_data.height); return fmt::format("- cant get block of height: {}", output_data.height);
} }
// get age of mixin relative to server time
pair<string, string> mixin_age = get_age(server_timestamp, pair<string, string> mixin_age = get_age(server_timestamp,
blk.timestamp, blk.timestamp,
FULL_AGE_FORMAT); FULL_AGE_FORMAT);
// get mixin transaction
transaction mixin_tx;
if (!mcore->get_tx(tx_out_idx.first, mixin_tx))
{
cerr << "Cant get tx: " << tx_out_idx.first << endl;
return fmt::format("Cant get tx: {:s}", tx_out_idx.first);
}
// mixin tx details
tx_details mixin_txd = get_tx_details(mixin_tx, true);
mixins.push_back(mstch::map { mixins.push_back(mstch::map {
{"mix_blk" , fmt::format("{:08d}", output_data.height)}, {"mix_blk" , fmt::format("{:08d}", output_data.height)},
{"mix_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", output_data.pubkey))}, {"mix_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}",
{"mix_tx_hash" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", tx_out_idx.first))}, output_data.pubkey))},
{"mix_tx_hash" , REMOVE_HASH_BRAKETS(fmt::format("{:s}",
tx_out_idx.first))},
{"mix_out_indx" , fmt::format("{:d}", tx_out_idx.second)}, {"mix_out_indx" , fmt::format("{:d}", tx_out_idx.second)},
{"mix_timestamp" , xmreg::timestamp_to_str(blk.timestamp)}, {"mix_timestamp" , xmreg::timestamp_to_str(blk.timestamp)},
{"mix_age" , mixin_age.first}, {"mix_age" , mixin_age.first},
{"mix_mixin_no" , mixin_txd.mixin_no},
{"mix_inputs_no" , mixin_txd.input_key_imgs.size()},
{"mix_outputs_no" , mixin_txd.output_pub_keys.size()},
{"mix_age_format" , mixin_age.second}, {"mix_age_format" , mixin_age.second},
{"mix_idx" , fmt::format("{:02d}", count)}, {"mix_idx" , fmt::format("{:02d}", count)},
}); });

@ -75,6 +75,8 @@
<tr> <tr>
<td>Mixin public key</td> <td>Mixin public key</td>
<td>blk</td> <td>blk</td>
<td>mixin</td>
<td>in/out</td>
<td>timestamp</td> <td>timestamp</td>
<td>age [y:d:h:m:s]</td> <td>age [y:d:h:m:s]</td>
</tr> </tr>
@ -82,6 +84,8 @@
<tr> <tr>
<td> - {{mix_idx}}: <a href="/tx/{{mix_tx_hash}}">{{mix_pub_key}}</a></td> <td> - {{mix_idx}}: <a href="/tx/{{mix_tx_hash}}">{{mix_pub_key}}</a></td>
<td>{{mix_blk}}</td> <td>{{mix_blk}}</td>
<td>{{mix_mixin_no}}</td>
<td>{{mix_inputs_no}}/{{mix_outputs_no}}</td>
<td>{{mix_timestamp}}</td> <td>{{mix_timestamp}}</td>
<td>{{mix_age}}</td> <td>{{mix_age}}</td>
</tr> </tr>

Loading…
Cancel
Save