Skip to main content

Module trust

Module trust 

Source
Expand description

Who is in the account’s network, as a provider of trust scores says (NIP-85).

An account may name, in a list of its own (kind 10040), somebody who works out how far it can trust other people: a provider, and the relay the provider keeps its answers on. An answer is a card (kind 30382) the provider signs about one person, for this account, with their rank from 0 to 100 on it. The account’s network is then itself, those it follows, and whoever the provider ranks at MIN_RANK or higher. Somebody the provider has no card for is outside it.

Nothing here is built in: with no such list, there is no network, and nothing is told apart by it. Which provider to trust, and with whose notes, is the account’s to say.

A card is asked for when there is a use for it, about the people a conversation on show is among and those who wrote to the account, and kept in the event store with everything else the relays sent. A person asked about once is not asked about again while Avestruz runs.

That the provider had no card for somebody is no event, and the store can’t keep it: it is kept beside it (Unranked), so that whoever was outside the network the last time is outside it at once the next time Avestruz runs, and not only when the provider’s relay has answered again. It is asked again all the same, once each run, the first time they turn up: a provider may come to rank somebody. What was not asked about for UNRANKED_KEPT_DAYS days is let go of.

flowchart TD
    person["Somebody who wrote in a conversation"] --> own{"The account itself, or somebody it follows?"}
    own -->|"yes"| inside["In the network"]
    own -->|"no"| asked{"Did the provider's relay answer about them?"}
    asked -->|"not yet, or it did not answer"| before{"Did it have no card for them, the last time it was asked?"}
    before -->|"yes"| outside
    before -->|"no"| unknown["Not known: nothing is made of it"]
    asked -->|"yes"| card{"Is there a card, with a rank of 5 or more?"}
    card -->|"yes"| inside
    card -->|"no"| outside["Outside the network"]

What is made of it is in crate::nostr::thread and in crate::nostr::notifications: a note from outside the network starts folded, in a conversation and among what the account is told of.

Only what the list says in the open is read. A provider the list names in its encrypted part is not looked for: reading it would ask the signer, which may be remote, every time Avestruz starts.

Structs§

Asking
What the provider is asked with, about those who wrote in a conversation: who it is, and the network as it stood when the question was put together, which says who need not be asked about.
Network
The account’s network, as things stand: who it is, who it follows, and what its provider said, if it has one.
Provider
Who works out ranks for the account, and where their cards are.
Ranks
What the provider said of the people it was asked about: a rank, or that it has none for them. Of anybody else, nothing is known.
Unranked
Who each provider had no card for, and when it last said so: what the event store can’t keep, there being no event that says it.

Constants§

CARD_KIND
The kind of a card: what a provider says of one person.
MIN_RANK
The lowest rank that is in the network.
PEOPLE_PER_FILTER 🔒
How many people one filter asks about.
PROVIDERS_KIND
The kind of the list an account names its providers in.
RANK_SERVICE 🔒
What a list calls the provider of ranks: the kind of its cards, and which of the things on them it is trusted for.
UNRANKED_FILE 🔒
The file that is kept in, in the directory of the event store.
UNRANKED_KEPT_DAYS
For how many days it is kept that a provider had no card for somebody, counted from when it was last asked about them.

Functions§

card_filters
The filters that ask for the cards of provider about people.
rank_on
Who card is about, and the rank it gives them, if it gives one. None of a card that is about nobody.
rank_provider
The provider of ranks that list, an account’s list of providers, names in the open: the first it names, if it names several.