simplewallet: fix output representation offset

This commit is contained in:
moneromooo-monero 2019-04-02 23:14:41 +00:00
parent 35e0a968bd
commit 588e670089
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
2 changed files with 3 additions and 3 deletions

View file

@ -5579,7 +5579,7 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
if (j == source.real_output) if (j == source.real_output)
highlight_height = heights[j]; highlight_height = heights[j];
} }
std::pair<std::string, std::string> ring_str = show_outputs_line(heights, highlight_height); std::pair<std::string, std::string> ring_str = show_outputs_line(heights, blockchain_height, highlight_height);
ostr << ring_str.first << tr("\n|") << ring_str.second << tr("|\n"); ostr << ring_str.first << tr("\n|") << ring_str.second << tr("|\n");
} }
// warn if rings contain keys originating from the same tx or temporally very close block heights // warn if rings contain keys originating from the same tx or temporally very close block heights

View file

@ -964,13 +964,13 @@ gamma_picker::gamma_picker(const std::vector<uint64_t> &rct_offsets, double shap
gamma = std::gamma_distribution<double>(shape, scale); gamma = std::gamma_distribution<double>(shape, scale);
THROW_WALLET_EXCEPTION_IF(rct_offsets.size() <= CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE, error::wallet_internal_error, "Bad offset calculation"); THROW_WALLET_EXCEPTION_IF(rct_offsets.size() <= CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE, error::wallet_internal_error, "Bad offset calculation");
const size_t blocks_in_a_year = 86400 * 365 / DIFFICULTY_TARGET_V2; const size_t blocks_in_a_year = 86400 * 365 / DIFFICULTY_TARGET_V2;
const size_t blocks_to_consider = rct_offsets.size() < blocks_in_a_year; const size_t blocks_to_consider = std::min<size_t>(rct_offsets.size(), blocks_in_a_year);
const size_t outputs_to_consider = rct_offsets.back() - (blocks_to_consider < rct_offsets.size() ? rct_offsets[rct_offsets.size() - blocks_to_consider - 1] : 0); const size_t outputs_to_consider = rct_offsets.back() - (blocks_to_consider < rct_offsets.size() ? rct_offsets[rct_offsets.size() - blocks_to_consider - 1] : 0);
begin = rct_offsets.data(); begin = rct_offsets.data();
end = rct_offsets.data() + rct_offsets.size() - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE; end = rct_offsets.data() + rct_offsets.size() - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE;
num_rct_outputs = *(end - 1); num_rct_outputs = *(end - 1);
THROW_WALLET_EXCEPTION_IF(num_rct_outputs == 0, error::wallet_internal_error, "No rct outputs"); THROW_WALLET_EXCEPTION_IF(num_rct_outputs == 0, error::wallet_internal_error, "No rct outputs");
average_output_time = DIFFICULTY_TARGET_V2 * rct_offsets.size() / num_rct_outputs; // this assumes constant target over the whole rct range average_output_time = DIFFICULTY_TARGET_V2 * blocks_to_consider / outputs_to_consider; // this assumes constant target over the whole rct range
}; };
gamma_picker::gamma_picker(const std::vector<uint64_t> &rct_offsets): gamma_picker(rct_offsets, GAMMA_SHAPE, GAMMA_SCALE) {} gamma_picker::gamma_picker(const std::vector<uint64_t> &rct_offsets): gamma_picker(rct_offsets, GAMMA_SHAPE, GAMMA_SCALE) {}