antlion-lacewing - v2.0.1
    Preparing search index...

    Class PostgresReplayStore

    A replay store shared by every process connected to one Postgres.

    Create the table once, the way you create your others:

    CREATE TABLE dpop_replay (
    key text PRIMARY KEY,
    expires_at timestamptz NOT NULL
    );
    CREATE INDEX ON dpop_replay (expires_at);

    Not UNLOGGED: an unlogged table is emptied after a crash, and every proof still inside its window is then accepted once more.

    Each proof is one INSERT ... ON CONFLICT (key) DO UPDATE ... WHERE the existing row has expired, so the key is recorded only if it is absent or dead, atomically, inside Postgres. Expiry is on the database's clock, so the nodes' clocks never meet here.

    Expired rows stay until PostgresReplayStore.deleteExpired removes them. Antlion starts no timers, so schedule it yourself.

    Implements

    Index
    • Delete every expired row, and resolve how many went. Nothing breaks if you never call it, except that the table grows by one row per accepted request. Once a minute is plenty: a row is dead maxProofAge plus six seconds after it was written.

      Returns Promise<number>