age format fixed for tx info

master
moneroexamples 9 years ago
parent 3a7174541e
commit a9c7808890

@ -88,6 +88,8 @@ namespace xmreg {
class page { class page {
static const bool FULL_AGE_FORMAT {true};
MicroCore* mcore; MicroCore* mcore;
Blockchain* core_storage; Blockchain* core_storage;
rpccalls rpc; rpccalls rpc;
@ -609,7 +611,7 @@ namespace xmreg {
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.8f}", XMR_AMOUNT(in_key.amount))}, {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))},
{"input_idx" , fmt::format("{:02d}", input_idx++)}, {"input_idx" , fmt::format("{:02d}", input_idx++)},
{"mixins" , mstch::array{}}, {"mixins" , mstch::array{}},
}); });
@ -640,10 +642,12 @@ namespace xmreg {
return fmt::format("- cant get block of height: {}\n", output_data.height); return fmt::format("- cant get block of height: {}\n", output_data.height);
} }
pair<string, string> mixin_age = get_age(server_timestamp, blk.timestamp); pair<string, string> mixin_age = get_age(server_timestamp,
blk.timestamp,
FULL_AGE_FORMAT);
mixins.push_back(mstch::map { mixins.push_back(mstch::map {
{"mix_blk" , fmt::format("{:d}", 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}", output_data.pubkey))},
{"mix_tx_hash" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", tx_out_idx.first))}, {"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)},
@ -687,7 +691,7 @@ namespace xmreg {
{ {
outputs.push_back(mstch::map { outputs.push_back(mstch::map {
{"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))}, {"out_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", outp.first.key))},
{"amount" , fmt::format("{:0.8f}", XMR_AMOUNT(outp.second))}, {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(outp.second))},
{"output_idx" , fmt::format("{:02d}", output_idx++)} {"output_idx" , fmt::format("{:02d}", output_idx++)}
}); });
} }
@ -750,10 +754,9 @@ namespace xmreg {
} }
pair<string, string> pair<string, string>
get_age(uint64_t timestamp1, uint64_t timestamp2) get_age(uint64_t timestamp1, uint64_t timestamp2, bool full_format = 0)
{ {
pair<string, string> age_pair; pair<string, string> age_pair;
// calculate difference between server and block timestamps // calculate difference between server and block timestamps
@ -768,7 +771,7 @@ namespace xmreg {
string age_format {"[h:m:s]"}; string age_format {"[h:m:s]"};
// if have days or years, change age format // if have days or years, change age format
if (delta_time[0] > 0) if (delta_time[0] > 0 || full_format == true)
{ {
age_str = fmt::format("{:02d}:{:02d}:{:02d}:{:02d}:{:02d}", age_str = fmt::format("{:02d}:{:02d}:{:02d}:{:02d}:{:02d}",
delta_time[0], delta_time[1], delta_time[2], delta_time[0], delta_time[1], delta_time[2],

@ -76,7 +76,7 @@
<td>Mixin public key</td> <td>Mixin public key</td>
<td>blk</td> <td>blk</td>
<td>timestamp</td> <td>timestamp</td>
<td>age</td> <td>age [y:d:h:m:s]</td>
</tr> </tr>
{{#mixins}} {{#mixins}}
<tr> <tr>

Loading…
Cancel
Save