Skip to main content

Module live_subs

Module live_subs 

Source
Expand description

Live subscriptions that outlast a relay closing them, and catch-ups for the gaps they leave.

nostr-sdk forgets a subscription a relay CLOSEs for any reason but auth-required or rate-limited, so neither a reconnect’s re-send nor an unchanged refresh would ask that relay again: the connection stays healthy while the feed is dead. Every live subscription is kept here with the filters each relay was sent, and is restored wherever a relay dropped it; the time it was down is then caught up from that relay.

revive is the return from being away (sleep, App Nap, a backgrounded app, a hidden window, a network change): every relay proves it is alive or is redialled, every live subscription is re-armed, and the platform’s CatchUp handler fetches what was missed.

Enums§

CatchUp
What a catch-up must cover.

Functions§

forget
Stop keeping id: it was unsubscribed or replaced.
heal
Restore every kept subscription a connected relay no longer holds. Cheap when nothing is missing: one local lookup per relay and subscription.
keep
Keep id live on each relay with the filters it was sent there.
keep_output
keep for a pool-wide subscribe: every relay it reached or failed on, with filters.
probe_or_redial
Every relay answers a cheap probe or has its socket redialled: a suspended process keeps sockets that died without closing. Returns how many connected relays had gone silent; one already down is only retried.
revive
Back from being away for away_ms: every relay answers a probe or is redialled, and every live subscription a relay dropped is restored. The full catch-up then runs when suspended (the process or its sockets were frozen: sleep, App Nap, a backgrounded app, a network change), after a long absence, or when anything was found broken; otherwise the live feed carried it all. A call while one runs, or just after, is the same return and does nothing.
set_catch_up
The platform’s catch-up: DMs and Communities for the live account. Set once at startup.
start_wake_watch
Notice the process waking from a suspension, whichever account is live, and revive it. Once per process.
watch
Watch client for relays closing a kept subscription, and check every kept one on a timer. Once per session.