mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-29 17:02:28 +00:00
Merge pull request #1979 from PR0M3TH3AN/ai/doc-client-20250224-5696189605440496000
chore(ai): document js/nostr/client.js
This commit is contained in:
3 files changed
+4
-4
No files matched your search
@@ -20,7 +20,7 @@ The client maintains three primary state maps to ensure data consistency:
|
||||
|
||||
* **`activeMap`** (`Map<string, VideoObject>`):
|
||||
* The "materialized view" used by the UI.
|
||||
* Keys are `videoRootId` (for versioned edits) or `pubkey:dTag` (for addressable events).
|
||||
* Keys are `videoRootId` (prefixed with `ROOT:`) for versioned edits, or `pubkey:dTag` for addressable events.
|
||||
* Values are the *latest* valid version of the video.
|
||||
* **Invariant**: Only one entry exists per "video entity", ensuring the UI displays the most recent edit.
|
||||
|
||||
@@ -36,7 +36,7 @@ The `subscribeVideos` method implements a buffered ingestion pipeline to handle
|
||||
|
||||
1. **Subscription**: Opens a subscription to all connected relays.
|
||||
2. **Buffering**: Incoming events are pushed to an `eventBuffer` array immediately.
|
||||
3. **Debouncing**: A timer flushes the buffer every ~250ms (or when full).
|
||||
3. **Debouncing**: A timer flushes the buffer every ~75ms (or when full).
|
||||
4. **Processing (Flush)**:
|
||||
* Events are parsed and validated.
|
||||
* **Tombstone Check**: If an event predates a known deletion, it is discarded.
|
||||
|
||||
+2
-1
@@ -3885,7 +3885,7 @@ export class NostrClient {
|
||||
* - Updates the `SyncMetadataStore` with the new max `created_at` on success.
|
||||
*
|
||||
* **Concurrency:**
|
||||
* - Batches relay requests in chunks of 4 to avoid saturating network connections.
|
||||
* - Batches relay requests in chunks of 8 to avoid saturating network connections.
|
||||
*
|
||||
* @param {object} params
|
||||
* @param {number} params.kind - The event kind to fetch (e.g. 10000 for mute list).
|
||||
@@ -3893,6 +3893,7 @@ export class NostrClient {
|
||||
* @param {string} [params.dTag] - Optional d-tag for addressable events (NIP-33).
|
||||
* @param {string[]} [params.relayUrls] - List of relays to query. Defaults to client's configured relays.
|
||||
* @param {function} [params.fetchFn] - Custom fetch function (mocks or specialized logic). Defaults to `pool.list`.
|
||||
* @param {number} [params.since] - Explicit start timestamp (overrides storage).
|
||||
* @param {number} [params.timeoutMs] - Optional per-relay timeout for list fetches; defaults to a higher list-friendly baseline.
|
||||
* @returns {Promise<import("nostr-tools").Event[]>} Deduplicated list of events found across all relays.
|
||||
*/
|
||||
|
||||
@@ -99,7 +99,6 @@ test("batchFetchProfiles handles fast and failing relays", async () => {
|
||||
nostrClient.relays = originalRelays;
|
||||
nostrClient.readRelays = originalReadRelays;
|
||||
nostrClient.writeRelays = originalWriteRelays;
|
||||
nostrClient.readRelays = originalReadRelays;
|
||||
nostrClient.pool = originalPool;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user