From 907a2aa4c78833ce93455567ae10ff2f506e752e Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Fri, 15 Feb 2013 15:27:57 -0800 Subject: Internal RNG for approximateBestSubset to prevent degenerate behavior. This fixes test_bitcoin failures on openbsd reported by dhill on IRC. On some systems rand() is a simple LCG over 2^31 and so it produces an even-odd sequence. ApproximateBestSubset was only using the least significant bit and so every run of the iterative solver would be the same for some inputs, resulting in some pretty dumb decisions. Using something other than the least significant bit would paper over the issue but who knows what other way a system's rand() might get us here. Instead we use an internal RNG with a period of something like 2^60 which is well behaved. This also makes it possible to make the selection deterministic for the tests, if we wanted to implement that. --- src/wallet.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/wallet.cpp') diff --git a/src/wallet.cpp b/src/wallet.cpp index 2317ac31ac..067473d087 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -973,6 +973,8 @@ static void ApproximateBestSubset(vector