mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-12 15:49:31 +02:00
random: make GetRand() support entire range (incl. max)
The existing code uses GetRand(nMax), with a default value for nMax, where nMax is the range of values (not the maximum!) that the output is allowed to take. This will always miss the last possible value (e.g. GetRand<uint32_t>() will never return 0xffffffff). Fix this, by moving the functionality largely in RandomMixin, and also adding a separate RandomMixin::rand function, which returns a value in the entire (non-negative) range of an integer.
This commit is contained in:
@@ -126,7 +126,7 @@ std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(int n_candida
|
||||
/*fRelevantServices=*/random_context.randbool(),
|
||||
/*m_relay_txs=*/random_context.randbool(),
|
||||
/*fBloomFilter=*/random_context.randbool(),
|
||||
/*nKeyedNetGroup=*/random_context.randrange(100),
|
||||
/*nKeyedNetGroup=*/random_context.randrange(100u),
|
||||
/*prefer_evict=*/random_context.randbool(),
|
||||
/*m_is_local=*/random_context.randbool(),
|
||||
/*m_network=*/ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())],
|
||||
|
||||
Reference in New Issue
Block a user