Skip to content

Commit c21cbe6

Browse files
committed
Introduce FastRandomContext::randbool()
1 parent 4bd0e9b commit c21cbe6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/random.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class FastRandomContext {
4242
return (Rw << 16) + Rz;
4343
}
4444

45+
bool randbool() {
46+
return rand32() & 1;
47+
}
48+
4549
uint32_t Rz;
4650
uint32_t Rw;
4751
};

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ static void ApproximateBestSubset(const std::vector<std::pair<CAmount, std::pair
20482048
//that the rng is fast. We do not use a constant random sequence,
20492049
//because there may be some privacy improvement by making
20502050
//the selection random.
2051-
if (nPass == 0 ? insecure_rand.rand32()&1 : !vfIncluded[i])
2051+
if (nPass == 0 ? insecure_rand.randbool() : !vfIncluded[i])
20522052
{
20532053
nTotal += vValue[i].first;
20542054
vfIncluded[i] = true;

0 commit comments

Comments
 (0)