aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJavier Smooth <iamjaviersmooth@gmail.com>2015-04-05 04:39:09 -0700
committerJavier Smooth <iamjaviersmooth@gmail.com>2015-04-05 04:39:09 -0700
commit83ddc942c1629d67b9897ba8be8632035527c6fc (patch)
treebf0d8a2e222a0be9fc0184ac1ff97d817e8ee28b /src
parenttriangular distribution to choose recent outputs more often for mixins (diff)
downloadmonero-83ddc942c1629d67b9897ba8be8632035527c6fc.tar.xz
handle unlikely rounding up after sqrt
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/blockchain_storage.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp
index a5e19b061..d59fc7a58 100644
--- a/src/cryptonote_core/blockchain_storage.cpp
+++ b/src/cryptonote_core/blockchain_storage.cpp
@@ -1086,6 +1086,9 @@ bool blockchain_storage::get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDO
uint64_t r = crypto::rand<uint64_t>() % ((uint64_t)1 << 53);
double frac = std::sqrt((double)r / ((uint64_t)1 << 53));
size_t i = (size_t)(frac*up_index_limit);
+ // just in case rounding up to 1 occurs after sqrt
+ if (i == up_index_limit)
+ --i;
if(used.count(i))
continue;
bool added = add_out_to_get_random_outs(amount_outs, result_outs, amount, i);