From 9df50a5b0d3debebd41fe5b427c4d8ec8954efae Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 23 Feb 2025 20:53:48 -0600 Subject: [PATCH] app.ts: minor variable name cleanup --- packages/ditto/app.ts | 13 ++++++------- packages/ditto/firehose.ts | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/ditto/app.ts b/packages/ditto/app.ts index 9f202786..13123e75 100644 --- a/packages/ditto/app.ts +++ b/packages/ditto/app.ts @@ -197,25 +197,24 @@ const pgstore = new DittoPgStore({ }); const pool = new DittoPool({ conf, relay: pgstore }); -const relaystore = new DittoRelayStore({ db, conf, relay: pgstore }); -const apistore = new DittoAPIStore({ relay: relaystore, pool }); +const relay = new DittoRelayStore({ db, conf, relay: pgstore }); -await seedZapSplits(apistore); +await seedZapSplits(relay); if (conf.firehoseEnabled) { startFirehose({ pool, - store: relaystore, + relay, concurrency: conf.firehoseConcurrency, kinds: conf.firehoseKinds, }); } if (conf.cronEnabled) { - cron({ conf, db, relay: relaystore }); + cron({ conf, db, relay }); } -const app = new DittoApp({ conf, db, relay: relaystore }, { strict: false }); +const app = new DittoApp({ conf, db, relay }, { strict: false }); /** User-provided files in the gitignored `public/` directory. */ const publicFiles = serveStatic({ root: './public/' }); @@ -246,7 +245,7 @@ app.get('/api/v1/streaming', socketTokenMiddleware, metricsMiddleware, ratelimit app.get( '/relay', (c, next) => { - c.set('relay', relaystore); + c.set('relay', new DittoAPIStore({ relay, pool })); return next(); }, metricsMiddleware, diff --git a/packages/ditto/firehose.ts b/packages/ditto/firehose.ts index f6f3d27f..1daca562 100644 --- a/packages/ditto/firehose.ts +++ b/packages/ditto/firehose.ts @@ -7,7 +7,7 @@ import { nostrNow } from '@/utils.ts'; interface FirehoseOpts { pool: NRelay; - store: NStore; + relay: NStore; concurrency: number; kinds: number[]; timeout?: number; @@ -19,7 +19,7 @@ interface FirehoseOpts { * and storing events for notifications and the home feed. */ export async function startFirehose(opts: FirehoseOpts): Promise { - const { pool, store, kinds, concurrency, timeout = 5000 } = opts; + const { pool, relay, kinds, concurrency, timeout = 5000 } = opts; const sem = new Semaphore(concurrency); @@ -32,7 +32,7 @@ export async function startFirehose(opts: FirehoseOpts): Promise { sem.lock(async () => { try { - await store.event(event, { signal: AbortSignal.timeout(timeout) }); + await relay.event(event, { signal: AbortSignal.timeout(timeout) }); } catch { // Ignore }