diff --git a/src/db/relays.ts b/src/db/relays.ts index 89c9fcb..d6f99c3 100644 --- a/src/db/relays.ts +++ b/src/db/relays.ts @@ -17,14 +17,15 @@ function addRelays(relays: `wss://${string}`[]) { .execute(); } -/** Get a list of all known good relays. */ -async function getAllRelays(): Promise { +/** Get a list of all known active relay URLs. */ +async function getActiveRelays(): Promise { const rows = await db .selectFrom('relays') .select('relays.url') + .where('relays.active', '=', true) .execute(); return rows.map((row) => row.url); } -export { addRelays, getAllRelays }; +export { addRelays, getActiveRelays }; diff --git a/src/firehose.ts b/src/firehose.ts index 4e5e3dc..689ebc3 100644 --- a/src/firehose.ts +++ b/src/firehose.ts @@ -1,5 +1,5 @@ import { insertEvent, isLocallyFollowed } from '@/db/events.ts'; -import { addRelays, getAllRelays } from '@/db/relays.ts'; +import { addRelays, getActiveRelays } from '@/db/relays.ts'; import { findUser } from '@/db/users.ts'; import { RelayPool } from '@/deps.ts'; import { trends } from '@/trends.ts'; @@ -7,7 +7,7 @@ import { isRelay, nostrDate, nostrNow } from '@/utils.ts'; import type { SignedEvent } from '@/event.ts'; -const relays = await getAllRelays(); +const relays = await getActiveRelays(); const pool = new RelayPool(relays); // This file watches events on all known relays and performs