Expand description
Global state management — ChatState, globals, processing gate.
All Tauri-specific globals (TAURI_APP) have been removed. Event emission
uses the EventEmitter trait via crate::traits::emit_event.
Structs§
- Chat
State - Chat
State Handle - The account’s chats and profiles in memory.
- Notified
Welcomes Handle - npubs already welcomed, so the greeting fires once per contact — per account, since the contact list is.
- Pending
Events Handle - Events parked while the processing gate is closed (encryption migration). Per-account: they are this account’s inbound traffic, awaiting its key.
- Pending
Invite Acceptance - Wrapper
IdCache - Wrapper
IdCache Handle - Which wrapper events this account has already ingested.
Statics§
- DISCOVERY_
READ_ ONLY_ RELAYS - Read-only Discovery Relays: queried when SYNCING relay lists but never published to. Ditto acks stranger kind-10050 writes with OK true and then silently drops them, so counting it as a publish landing would falsely advance the list-freshness anchor — but it serves ESTABLISHED accounts’ lists honestly, and those are exactly the users whose existing list a fresh Vector login must find before it dares bootstrap-publish.
- DISCOVERY_
RELAYS - Discovery Relays: widely-used indexers queried/written for relay-list events (kind 10050) ONLY — never DMs, profiles, or communities. They give list syncs and publishes a rendezvous point that doesn’t depend on the user’s own relay set overlapping anyone else’s. Every entry must be verified to ACCEPT AND SERVE kind 10050 from unknown pubkeys (write + readback); accept-then-silently-drop policy relays reduce coverage invisibly.
- ENCRYPTION_
ENABLED - ENCRYPTION_
KEY - MNEMONIC_
SEED - MY_
SECRET_ KEY - NOTIFIED_
WELCOMES - PENDING_
BUNKER_ SETUP - Staged bunker metadata between
connect_bunker/start_nostrconnect_sessionand the subsequent encryption-flow commit. URL is wrapped inZeroizingbecause it contains the NIP-46 single-use pairing secret; the pubkey hex is non-secret.setup_encryption/skip_encryptionreads this whensigner_kind() == Bunkerto write the right settings rows viacommit_bunker_account_setup. - PENDING_
EVENTS - PENDING_
NIP55_ SETUP - Staged NIP-55 pairing result between
login_with_nip55and the subsequent encryption-flow commit. Both fields are public material (identity pubkey + signer package name), so noZeroizing— unlike bunker, a NIP-55 account stages nothing secret.setup_encryption/skip_encryptionreads this whensigner_kind() == Nip55to write the right settings rows viacommit_nip55_account_setup. - PENDING_
NSEC - PROCESSING_
GATE - STATE
- TRUSTED_
RELAYS - WRAPPER_
ID_ CACHE
Functions§
- active_
trusted_ relays - clear_
message_ tombstones - Drop the delete-tombstone set on an account switch.
- clear_
my_ public_ key - Clear
MY_PUBLIC_KEY. The Nostr client is taken separately viatake_nostr_client()so the caller can shut it down before this clear. - clear_
pending_ bunker_ setup - clear_
pending_ invite - clear_
pending_ nip55_ setup - close_
processing_ gate - discovery_
relay_ iter - Every discovery relay url (writable + read-only) — the fetch/pool/identity
set. Publish copies use
DISCOVERY_RELAYSalone. - get_
active_ chat - get_
blossom_ servers - has_
active_ session - Returns
truewhen there is an active session (client + pubkey set). - init_
blossom_ servers - init_
encryption_ enabled - is_
encryption_ enabled_ fast - is_
processing_ allowed - my_
public_ key - Get the active user’s public key.
PublicKeyisCopy, so this is by-value. - nostr_
client - Get a clone of the active Nostr client. The clone is cheap —
Clientis internallyArc-counted, so all clones share connections, signers, and subscription state. ReturnsNonewhen no session is active. - note_
message_ deleted - Record that
message_idwas deleted this session (called where the deletion is decided). - open_
processing_ gate - pending_
bunker_ setup - pending_
invite - pending_
nip55_ setup - resolve_
encryption_ enabled - Resolve “is this account encrypted?” from raw DB settings. Single source of truth — every caller (crypto::is_encryption_enabled, init_encryption_enabled, Android bg-sync) delegates here, so the answer is consistent regardless of code path.
- resolve_
encryption_ enabled_ from_ db - Resolve from the current account’s DB via the global settings helper.
Returns
falseif the DB is not yet open. - seed_
message_ tombstones - Seed the tombstone set from the account’s durable
deleted_messagesrows, makingwas_message_deletedsurvive restarts and account swaps. Called at account DB init (the set was cleared by the session bump on swap). - set_
active_ chat - set_
blossom_ servers - Install this account’s resolved server list.
- set_
encryption_ enabled - set_
my_ public_ key - Install the active user’s public key for the current session.
- set_
nostr_ client - Install the Nostr client for the current session. Replaces any prior client
without shutting it down —
reset_session()is responsible for orderly teardown of the outgoing client. - set_
nostr_ client_ if_ absent - Install
clientonly if this session has none yet, reporting whether it took. Logins race on Android, where a service-only background sync can install a client before the Activity’s login reaches this point; the loser must drop its own rather than replace a live one. - set_
pending_ bunker_ setup - set_
pending_ invite - set_
pending_ nip55_ setup - take_
nostr_ client - Atomically take the current Nostr client out of global state.
Used by
reset_session()so the post-take shutdown call doesn’t race with new readers. - was_
message_ deleted - Whether
message_idwas deleted this session.