Tumbler
Purpose
A mixing node's holding pen — the cells it has admitted and not yet released. A tumbler does the one thing that makes a mix a mix: it waits. A cell that arrived is held with others until the pen has gathered a batch, and only then are they let out together, reordered, so that the order and timing a cell left by tell an observer nothing about the order and timing it arrived by. The threshold is how full the pen must be before it releases; a pool of tumblers, each holding and reordering, is what decorrelates a sender's fan of cells from each other and from the sender. The tumbler is an immutable snapshot — admitting a cell produces the next tumbler, and releasing produces an emptied one; nothing is mutated in place.
Attributes
- holding: the
Cellsadmitted and not yet released, in arrival order - threshold: how many cells the pen gathers before it releases a batch, a count
Invariants
- The threshold is at least one — a pen that released on every arrival would mix nothing.
Operations
admit
Produces a new Tumbler that also holds a given Cell, alongside those it already holds.
Result: self
ready
Reports whether the tumbler has gathered its threshold — whether it is time to release a batch.
Result: whether the threshold is gathered, as Truth
emptied
Produces a new Tumbler holding nothing — what remains once a ready pen has released its batch. Result: self
Scenarios
A pen gathers cells until it is ready
Given: an empty Tumbler with threshold 3 When: two Cells are admitted in turn Then: the tumbler holds both, and ready reports false — the batch is not yet gathered
A full pen is ready to release
Given: an empty Tumbler with threshold 2 When: two Cells are admitted in turn Then: the tumbler holds both, and ready reports true
A threshold below one is rejected
Given: holding no cells and threshold 0 When: a Tumbler is created Then: the creation is rejected because a tumbler that released on every arrival would mix nothing