Merge branch 'pool-worker' into 'main'
Move the RelayPool to a worker thread See merge request soapbox-pub/ditto!78
This commit is contained in:
commit
5cbfbe5eaa
|
@ -9,7 +9,7 @@ export {
|
|||
} from 'https://deno.land/x/hono@v3.10.1/mod.ts';
|
||||
export { cors, logger, serveStatic } from 'https://deno.land/x/hono@v3.10.1/middleware.ts';
|
||||
export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
|
||||
export { RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.6.30';
|
||||
export { RelayPoolWorker } from 'https://dev.jspm.io/nostr-relaypool@0.6.30';
|
||||
export {
|
||||
type Event,
|
||||
type EventTemplate,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { getActiveRelays } from '@/db/relays.ts';
|
||||
import { Debug, type Event, RelayPool } from '@/deps.ts';
|
||||
import { Debug, type Event, RelayPoolWorker } from '@/deps.ts';
|
||||
|
||||
const debug = Debug('ditto:pool');
|
||||
|
||||
|
@ -7,7 +7,10 @@ const activeRelays = await getActiveRelays();
|
|||
|
||||
console.log(`pool: connecting to ${activeRelays.length} relays.`);
|
||||
|
||||
const pool = new RelayPool(activeRelays, {
|
||||
const worker = new Worker('https://unpkg.com/nostr-relaypool@0.6.30/lib/nostr-relaypool.worker.js', { type: 'module' });
|
||||
|
||||
// @ts-ignore Wrong types.
|
||||
const pool = new RelayPoolWorker(worker, activeRelays, {
|
||||
// The pipeline verifies events.
|
||||
skipVerification: true,
|
||||
// The logging feature overwhelms the CPU and creates too many logs.
|
||||
|
|
Loading…
Reference in New Issue