macula_publication_seq (macula v11.5.0)
View SourceThe seq counter of the publications a node signs, one per key.
All publications a node signs with one key share one counter (DESIGN_PQ_SIGNED_FRAMES_AND_RECORDS.md, Publications), so a pool and a pubsub server signing with the same key never interleave two counters, which an ordering subscriber would read as a restart at every switch. A key's counter starts at the wall clock in microseconds the first time the key publishes, and adds one for each publication after that.
This process owns the counter table and runs under macula_root. next/1 updates the table atomically from the caller's process. If the table is lost with its owner, the clock seeds each counter again, which puts the next number above every number handed out before, as long as the key published less than once per microsecond on average.
Summary
Types
-type options() :: #{table => atom(), clock => fun(() -> non_neg_integer())}.
Functions
-spec next(<<_:256>>) -> non_neg_integer().
The next seq for a publication signed with the key whose key id is KeyId.
-spec next(atom(), <<_:256>>) -> non_neg_integer().
As next/1, from the counter table Table.