Skip to main content

Module dm_catchup

Module dm_catchup 

Source
Expand description

DM catch-up: what our read relays hold for us that we don’t, fetched once each.

Each relay reconciles (NIP-77) only the window it hasn’t vouched for: from its cursor, less NIP-59’s backdating slack. On an established account that is a few kilobytes of fingerprints. What a relay names missing is fetched from that relay alone, so a wrap five relays hold comes down once, not five times. A relay that can’t reconcile walks its window in small pages instead. Everything commits as it lands, so a link that dies part-way keeps what came. Fetches wait for silence, not a total: a slow relay that keeps sending keeps its turn. A relay’s cursor advances only once its whole window is held.

Structs§

Opts
Report

Constants§

NIP59_BACKDATE_SLACK
NIP-59 backdates a wrap’s created_at by up to two days, so a window that reaches back to a cursor has to start this much before it.
RETRY_BACKOFF_SECS
After an incomplete catch-up, the waits before each retry: soon, then less often.
SAFETY_NET_SECS
A catch-up this often while the app runs: a live subscription can die without a word, and the window since the last one is a few fingerprints.

Functions§

catch_up
Catch up on DMs over the read relays (or opts.only). Each event goes through commit (a shell’s own commit, which may intercept, around the core one) with the shared batcher holding the persists.
retry_incomplete
Retry what a catch-up left incomplete, backing off, until every relay is held or the account is swapped out. run catches up the relays it’s given.
start_safety_net
Catch up every SAFETY_NET_SECS for as long as this account is the one logged in. Once per account however often it’s called.