switch kind-zero finder to use NPool

This commit is contained in:
Siddharth Singh 2024-06-10 14:00:40 +05:30
parent 46e9ae4d3d
commit 470b690e24
No known key found for this signature in database

View file

@ -8,6 +8,7 @@ import { PoolStore } from '@/storages/pool-store.ts';
import { SearchStore } from '@/storages/search-store.ts'; import { SearchStore } from '@/storages/search-store.ts';
import { InternalRelay } from '@/storages/InternalRelay.ts'; import { InternalRelay } from '@/storages/InternalRelay.ts';
import { UserStore } from '@/storages/UserStore.ts'; import { UserStore } from '@/storages/UserStore.ts';
import { NPool, NRelay1 } from '@nostrify/nostrify';
export class Storages { export class Storages {
private static _db: Promise<EventsDB> | undefined; private static _db: Promise<EventsDB> | undefined;
@ -46,9 +47,6 @@ export class Storages {
public static async kind0Finder(): Promise<PoolStore> { public static async kind0Finder(): Promise<PoolStore> {
if (this._kind0Finder) return this._kind0Finder; if (this._kind0Finder) return this._kind0Finder;
const worker = new Worker('https://unpkg.com/nostr-relaypool2@0.6.34/lib/nostr-relaypool.worker.js', {
type: 'module',
});
const DEFAULT_RELAYS = [ const DEFAULT_RELAYS = [
'wss://nos.lol', 'wss://nos.lol',
@ -59,12 +57,13 @@ export class Storages {
'wss://relay.primal.net', 'wss://relay.primal.net',
]; ];
// @ts-ignore Wrong types. const pool = new NPool({
const pool = new RelayPoolWorker(worker, DEFAULT_RELAYS, { open(url) {
autoReconnect: true, return new NRelay1(url);
skipVerification: false, },
logErrorsAndNotices: false, async reqRelays() { return DEFAULT_RELAYS },
}); async eventRelays() { return [] }
})
return this._kind0Finder = new PoolStore({ pool, relays: DEFAULT_RELAYS }); return this._kind0Finder = new PoolStore({ pool, relays: DEFAULT_RELAYS });
} }