aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-02-17 16:32:16 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2017-03-29 00:40:17 -0700
commitc21cbe61c6249bcfca098705df6f9b4baab9f296 (patch)
treeddc52711d82709261d7fdfb541dee9a5f7e76079 /src
parent4bd0e9b90a39c5c6a016b83882ae44cb4d28f1f8 (diff)
downloadbitcoin-c21cbe61c6249bcfca098705df6f9b4baab9f296.tar.xz
Introduce FastRandomContext::randbool()
Diffstat (limited to 'src')
-rw-r--r--src/random.h4
-rw-r--r--src/wallet/wallet.cpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/random.h b/src/random.h
index 0464bdce14..82886bec59 100644
--- a/src/random.h
+++ b/src/random.h
@@ -42,6 +42,10 @@ public:
return (Rw << 16) + Rz;
}
+ bool randbool() {
+ return rand32() & 1;
+ }
+
uint32_t Rz;
uint32_t Rw;
};
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 39e2ab7c1f..2f9d47aa0f 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2048,7 +2048,7 @@ static void ApproximateBestSubset(const std::vector<std::pair<CAmount, std::pair
//that the rng is fast. We do not use a constant random sequence,
//because there may be some privacy improvement by making
//the selection random.
- if (nPass == 0 ? insecure_rand.rand32()&1 : !vfIncluded[i])
+ if (nPass == 0 ? insecure_rand.randbool() : !vfIncluded[i])
{
nTotal += vValue[i].first;
vfIncluded[i] = true;