Move the RelayPool to a worker thread
This commit is contained in:
parent
44689ac781
commit
107fe76fdf
|
@ -9,7 +9,7 @@ export {
|
||||||
} from 'https://deno.land/x/hono@v3.10.1/mod.ts';
|
} 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 { 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 { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
|
||||||
export { Author, RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.6.30';
|
export { Author, RelayPoolWorker } from 'https://dev.jspm.io/nostr-relaypool@0.6.30';
|
||||||
export {
|
export {
|
||||||
type Event,
|
type Event,
|
||||||
type EventTemplate,
|
type EventTemplate,
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import { getActiveRelays } from '@/db/relays.ts';
|
import { getActiveRelays } from '@/db/relays.ts';
|
||||||
import { type Event, RelayPool } from '@/deps.ts';
|
import { type Event, RelayPoolWorker } from '@/deps.ts';
|
||||||
|
|
||||||
const activeRelays = await getActiveRelays();
|
const activeRelays = await getActiveRelays();
|
||||||
|
|
||||||
console.log(`pool: connecting to ${activeRelays.length} relays.`);
|
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.
|
// The pipeline verifies events.
|
||||||
skipVerification: true,
|
skipVerification: true,
|
||||||
// The logging feature overwhelms the CPU and creates too many logs.
|
// The logging feature overwhelms the CPU and creates too many logs.
|
||||||
|
|
Loading…
Reference in New Issue