mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 12:22:28 +00:00
lists: cap login list subscriptions to the §17 read set (≤8)
The cold-login REQ storm came from list subsystems subscribing/fetching across the user's full NIP-65 relay set (often ~20) instead of the documented §17 read cap. The fetchListIncrementally paths already route through capReadRelays, but the live subscriptions and direct pool.list calls bypassed it: - userBlocks.ensureBlockListSubscription: cap the live block-list subscription - subscriptions.ensureSubscriptionListSubscription: cap the live follows-list subscription - hashtagPreferencesService: cap the relay set used by pool.list + fetch capReadRelays keeps the user's own relays first and guarantees the reserved defaults, bounded to MAX_SUBSCRIBE_RELAYS (8). Trade-off accepted: a list event living only on a user's 9th+ relay may sync on a later pass rather than at login. Regression: tests/user-blocks-relay-cap.test.mjs. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
7f6a0f3adf
commit
2c62b959fd
4 files changed
+85
-8
No files matched your search
+8
-3
@@ -10,7 +10,7 @@ import {
|
||||
listVideoViewEvents,
|
||||
subscribeVideoViewEvents,
|
||||
} from "./nostrViewEventsFacade.js";
|
||||
import { DEFAULT_RELAY_URLS } from "./nostr/toolkit.js";
|
||||
import { DEFAULT_RELAY_URLS, capReadRelays } from "./nostr/toolkit.js";
|
||||
import { relayManager } from "./relayManager.js";
|
||||
import {
|
||||
buildSubscriptionListEvent,
|
||||
@@ -730,6 +730,11 @@ class SubscriptionsManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Bound the live follows-list subscription to the §17 read cap (≤8, user
|
||||
// relays first + reserved defaults) so it doesn't fan out across the user's
|
||||
// full NIP-65 set during the cold-login REQ storm.
|
||||
const cappedRelays = capReadRelays(relays);
|
||||
|
||||
const key = `subscriptions:${normalized}`;
|
||||
this.subscriptionKey = key;
|
||||
|
||||
@@ -751,7 +756,7 @@ class SubscriptionsManager {
|
||||
if (manager) {
|
||||
this.subscriptionHandle = manager.subscribe({
|
||||
key,
|
||||
relays,
|
||||
relays: cappedRelays,
|
||||
filters,
|
||||
label: "subscription-list",
|
||||
onEvent: (event) => this.handleSubscriptionListEvent(event),
|
||||
@@ -762,7 +767,7 @@ class SubscriptionsManager {
|
||||
return relaySubscriptionService.ensureSubscription({
|
||||
key,
|
||||
pool: nostrClient.pool,
|
||||
relays,
|
||||
relays: cappedRelays,
|
||||
filters,
|
||||
label: "subscription-list",
|
||||
onEvent: (event) => this.handleSubscriptionListEvent(event),
|
||||
|
||||
Reference in new issue
Block a user