Expand description
general helpers
Structs§
- Helper which allows producing random numbers within a range and preventing duplicates If consumed as a regular iterator, will return a randomly ordered permutation of all values from 0..max
- Provides parameters to use the RandomOverlapQuorumIterator
- Constructs a quorum with a random number of members and overlaps. Functions similar to StableQuorumIterator, except that the number of MEMBERS and OVERLAP are also (deterministically) random, to allow additional variance in testing.
- Provides parameters to use the StableQuorumIterator
- Iterator which returns odd/even values for a given COUNT of nodes. For OVERLAP=0, this will return [0, 2, 4, 6, …] for an even round, and [1, 3, 5, 7, …] for an odd round. Setting OVERLAP>0 will randomly introduce OVERLAP elements from the previous round, so an even round with OVERLAP=2 will contain something like [1, 7, 2, 4, 0, …]. Note that the total number of nodes will always be COUNT/2, so for OVERLAP>0 a random number of nodes which would have been in the round for OVERLAP=0 will be dropped. Ordering of nodes is random. Outputs is deterministic when prev_rng and this_rng are provided by make_rngs using the same values for SEED and ROUND.
Traits§
- Trait wrapping a config for quorum filters. This allows selection between either the StableQuorumIterator or the RandomOverlapQuorumIterator functionality from above
Functions§
- Determines how many possible values can be made for the given odd/even E.g. if count is 5, then possible values would be [0, 1, 2, 3, 4] if odd = true, slots = 2 (1 or 3), else slots = 3 (0, 2, 4)
- Create a pair of PRNGs for the given SEED and ROUND. Prev_rng is the PRNG for the previous ROUND, used to deterministically replay random numbers generated for the previous ROUND.
- Create a single u64 seed by merging two u64s. Done this way to allow easy seeding of the number generator from both a stable SOUND as well as a moving value ROUND (typically, epoch). Shift left by 8 to avoid scenarios where someone manually stepping seeds would pass over the same space of random numbers across sequential rounds. Doesn’t have to be 8, but has to be large enough that it is unlikely that a given test run will collide; using 8 means that 256 rounds (epochs) would have to happen inside of a test before the test starts repeating values from SEED+1.
- Helper function to convert the arguments to a StableQuorumIterator into an ordered set of values.
- Helper function to convert the arguments to a StableQuorumIterator into an ordered set of values.