From 327fb1756fd3098ce1fea10820a5617b11c04149 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 6 Oct 2016 08:41:43 +0800 Subject: [PATCH] showing real mixin on timescale added --- src/page.h | 29 +++++++++++++++++++++++++- src/templates/partials/tx_details.html | 3 ++- src/tools.cpp | 6 ++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/page.h b/src/page.h index 2602c0e..891867d 100644 --- a/src/page.h +++ b/src/page.h @@ -1477,7 +1477,8 @@ namespace xmreg { { // get public keys of real outputs - vector real_output_pub_keys; + vector real_output_pub_keys; + vector real_output_indices; for (const tx_source_entry& tx_source: ptx.construction_data.sources) { @@ -1502,6 +1503,8 @@ namespace xmreg { real_output_pub_keys.push_back( REMOVE_HASH_BRAKETS(fmt::format("{:s}",real_out_pub_key)) ); + + real_output_indices.push_back(tx_source.real_output); } mstch::map tx_context = construct_tx_context(ptx.tx); @@ -1509,6 +1512,7 @@ namespace xmreg { // get reference to inputs array created of the tx mstch::array& inputs = boost::get(tx_context["inputs"]); + // mark which mixin is real in each input's mstch context for (mstch::node& input_node: inputs) { mstch::array& mixins = boost::get( @@ -1531,9 +1535,32 @@ namespace xmreg { mixin["mix_is_it_real"] = true; } } + } + + // mark real mixing in the mixins timescale graph + mstch::array& mixins_timescales + = boost::get(tx_context["timescales"]); + + + uint64_t idx {0}; + + for (mstch::node& timescale_node: mixins_timescales) + { + + string& timescale = boost::get( + boost::get(timescale_node)["timescale"] + ); + boost::iterator_range r + = boost::find_nth(timescale, "*", real_output_indices.at(idx)); + + *(r.begin()) = 'R'; + //timescale.insert(*(r.begin()), "*"); + + ++idx; } + boost::get(context["txs"]).push_back(tx_context); } diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index ad17bd0..f522a5c 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -110,7 +110,8 @@ {{#has_inputs}}

Inputs' mixins time scale (from {{min_mix_time}} till {{max_mix_time}}; - resolution: {{timescales_scale}} days)

+ resolution: {{timescales_scale}} days + {{#have_raw_tx}} R - real mixin {{/have_raw_tx}})
    {{#timescales}} diff --git a/src/tools.cpp b/src/tools.cpp index b20b3be..bc13b73 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -590,7 +590,9 @@ namespace xmreg pair timestamps_time_scale(const vector& timestamps, - uint64_t timeN, uint64_t resolution, uint64_t time0) + uint64_t timeN, + uint64_t resolution, + uint64_t time0) { string empty_time = string(resolution, '_'); @@ -610,7 +612,7 @@ namespace xmreg } uint64_t timestamp_place = double(timestamp-time0) - / double(interval_length)*(time_axis_length-1); + / double(interval_length)*(time_axis_length - 1); empty_time[timestamp_place + 1] = '*'; }