Expand description
The relay client and the local event store behind it.
NostrService wraps the nostr-sdk relay pool. Every event a relay sends
is checked (signature and id) by the SDK and kept in an LMDB store, so what
was seen once is there at once on the next start, before any relay answers.
Each relay is asked for itself, and which of them sent a note is kept
(see Sightings): the pool, asked as one, gives each event once and
says no more than who was first.
There are two pools. One holds the account’s own relays: those the
config names, and those the account’s relay list (NIP-65) says it writes
to. They are asked about everything, and are where what the account
writes goes. The other holds other people’s relays, the ones their
relay lists name: asked about those people alone, for what the
account’s own relays may not have, and sent what is meant for them (see
crate::nostr::outbox). They come and go: so many at a time, each
let go of when it has not been used for a while.
flowchart TB
subgraph service["NostrService"]
home["The home pool: the account's own relays"]
others["The pool of other people's relays"]
private["The relay it runs itself"]
store[("One event store")]
end
asked["A question"] -->|"about anyone"| home
asked -->|"about the people who list a relay"| others
written["What the account writes"] --> home
written -->|"if it names someone"| others
draft["A draft"] --> private
home --> store
others --> store
private --> store
store -->|"what is shown is read from here"| shown["The model"]§Finding one’s way in this file
It is long, and in this order:
The decisions all of this carries out (which relay is asked what,
whose word is taken for a relay, where what is written goes) are told
in one place, with their diagrams: crate::guide::relays.
Structs§
- Asked 🔒
- What a relay sent when it was asked.
- Nostr
Service - The Nostr client: a relay pool over a local event store. Cheap to clone; clones share the pool and the store.
- Notified
- One page of what an account is told of.
- Own 🔒
- The account’s own relays: those the config names, those its relay list names, and which of them are in use.
- Reach
- How far other people’s relays are reached for.
- Reached 🔒
- What is remembered of reaching for other people’s relays.
- Relay
Use - How a relay this is connected to has been doing, since the applet started: what the relays page says under its name.
Enums§
- Fetch
Error - Why a request to the relays brought nothing back.
- Follow
Error - Why an account’s contact list was not changed.
- List
Error - Why a list an account keeps part of to itself (its bookmarks, its search relays) or its relay list was not read, or not changed.
- Pool 🔒
- Which pool a relay is in.
- Publish
Error - Why an event did not go out.
- Source
- Where events are looked for.
Constants§
- ABOUT_
WAIT 🔒 - How long the relays are given to send the notes notifications are about, which only say what was answered or reacted to.
- ACCOUNT_
RELAYS_ 🔒MAX - How many of the relays an account’s own relay list says it writes to are joined to the ones the config names.
- AUTHORS_
PER_ 🔒FILTER - How many authors one filter names. Relays refuse filters past some size, each its own; a long follow list is asked about in filters of this many.
- CONNECT_
GRACE 🔒 - How long after startup a request still waits for relays that are in the middle of connecting, so the first page comes from all of them rather than from whichever answered first. After this, a relay that is still trying is left out of a request instead of holding it up.
- CONNECT_
POLL 🔒 - How often the relays’ connection states are looked at while waiting.
- CONNECT_
WAIT 🔒 - How long a request waits for a first relay to connect before giving up.
- DELIVERED_
KINDS 🔒 - The kinds of event that are sent to the people they name, as well as to the account’s own relays: what is said to someone, or done to what they wrote. Not a contact list, say, which names everyone followed.
- ENGAGEMENT_
LIMIT 🔒 - ENGAGEMENT_
NOTES_ 🔒PER_ REQUEST - How many notes one request asks about at a time, when asking what was made of them, and how many events of a kind it asks for: a note that went everywhere has more reactions than are worth carrying.
- ENGAGEMENT_
STORE_ 🔒LIMIT - How many events of a kind the store is read for, for as many notes. More than a request brings, since the store keeps what earlier requests brought.
- FEED_
KINDS 🔒 - The kinds of event a list of notes is made of: text notes, and comments (NIP-22), which are replies to what is not a text note.
- FEED_
PAGE - How many notes one page of a feed asks for.
- FETCH_
TIMEOUT 🔒 - How long relays get to answer a request. Every query has one, so nothing loads forever on a relay that stopped answering.
- HOLDER_
WAIT 🔒 - How long the relays get to say which of them has an event that is about to be pointed at. Short: what points at it goes out without, rather than late.
- IDS_
PER_ 🔒FILTER - How many notes one filter asks for by id.
- PUBLISH_
TIMEOUT 🔒 - How long each relay gets to say whether it took an event.
- QUOTES_
WAIT 🔒 - How long the relays get to send the notes that the notes of a page quote, and again for those that these quote in turn. The page waits for them, so that a note is shown with what it quotes or without, and not first one way and then the other.
- REACH_
AVOID 🔒 - How long a relay that did not connect, said no to what it was asked, or did not answer in time is left alone, and the others asked without it; and how near the time it had counts as running out of it.
- REACH_
BUSY 🔒 - REACH_
CAP 🔒 - How many of other people’s relays one question reaches for, and how many are kept in their pool once those in use are done with, unless said otherwise.
- REACH_
CONNECT_ 🔒WAIT - How long one of other people’s relays gets to connect, and to answer. Shorter than the account’s own get: they are asked for what may well be had already, and a list of notes waits for the slowest of them.
- REACH_
KEEP 🔒 - REACH_
SLEEP 🔒 - How long one of other people’s relays stays connected with nothing asked of it, how long it stays in the pool unused, and how lately it must have been used not to be let go of to make room for another.
- REACH_
TIMEOUT 🔒 - RECEIPT_
LIMIT 🔒 - How many of a note’s newest receipts are looked at when the listening starts: enough to find one that arrived just before.
- RECEIPT_
RETRY 🔒 - How long to wait before listening again, when the relays stopped answering in the middle of waiting for a receipt.
- RECEIPT_
WAIT 🔒 - How long the receipt of a zap is waited for after its invoice is shown: about as long as such an invoice can be paid.
- RELAYS_
PER_ 🔒PERSON - How many relays each person is read from, the account’s own among them, when their relay list names as many; and how many of the relays each person reads are sent what is meant for them.
- RELAY_
LISTS_ 🔒FRESH - How long someone’s relay list is taken as known before the relays are asked for it again.
- SEARCH_
TIMEOUT 🔒 - How long a relay that searches gets to answer.
- THREAD_
ANCESTORS 🔒 - How many notes up from the one a thread was opened for are looked for one by one, when nothing else brought them.
- THREAD_
ASK_ 🔒AGAIN_ UNDER - A conversation with fewer notes than this naming its root is asked about again, for the notes that name only the note they answer. A larger one has enough to show without the second request.
- THREAD_
LIMIT 🔒 - How many notes of a conversation one request asks for. A thread that went everywhere has thousands; this many are read, and held, at most.
- THREAD_
PEOPLE 🔒 - How many of the people a note names are taken for part of its conversation, when their relays are asked about it.
- TIMEOUT_
SLACK 🔒
Functions§
- default_
store_ path - Where the event store lives: the user’s data directory, not the cache. It is what the embedded relay will serve, so it is not disposable.
- engagement_
filters 🔒 - The filters that ask what was made of
notes: the replies (notes and comments), reposts, reactions and zap receipts that name them,limitof each at most, and the reactions and reposts ofaccount, which must not be among those left out. - feed_
filters 🔒 - filters_
by_ 🔒id - The filters that ask for one page of the notes of
authors: text notes and comments, thelimitnewest written at or beforeuntil. One filter for everyAUTHORS_PER_FILTERauthors, and none for nobody. - newest 🔒
- The newest of
events, which are the versions of something only the last of which counts: a contact list, a bookmark list.Noneif there is none. - newest_
profiles 🔒 - Each author’s newest profile among
events.