Introduce FastRandomContext::randbool()

This commit is contained in:
Pieter Wuille committed 2017-03-29 00:40:17 -07:00
1 parent 4bd0e9b90a
commit c21cbe61c6
2 files changed
+5 -1

No files matched your search

+4
View File
@@ -42,6 +42,10 @@ public:
return (Rw << 16) + Rz;
}
bool randbool() {
return rand32() & 1;
}
uint32_t Rz;
uint32_t Rw;
};
+1 -1
View File
@@ -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;