/** * Shared SimplePool for all relay connections in the app. * * Every service previously created its own SimplePool (client.service, * graph-query.service, EventBrowserTab, RecoveryTab), and each pool opens a * separate WebSocket per relay. With multiple pools alive at once, one client * could hold many connections to the same relay (main pool + graph pool + * tab pools + cache relay), tripping per-IP connection caps on personal * relays. A single shared pool guarantees exactly one connection per relay * across the whole app. * * Note: `trackRelays` is enabled so `seenOn` metadata works for the main * client service. */ import { SimplePool } from 'nostr-tools' const sharedPool = new SimplePool() ;(sharedPool as SimplePool & { trackRelays?: boolean }).trackRelays = true export function getSharedPool(): SimplePool { return sharedPool } /** Close all connections held by the shared pool. */ export function closeSharedPool(relays: string[]): void { sharedPool.close(relays) }