Use only "active" relays in the pool
This commit is contained in:
parent
a0769d7c92
commit
882a3fe203
|
@ -17,14 +17,15 @@ function addRelays(relays: `wss://${string}`[]) {
|
|||
.execute();
|
||||
}
|
||||
|
||||
/** Get a list of all known good relays. */
|
||||
async function getAllRelays(): Promise<string[]> {
|
||||
/** Get a list of all known active relay URLs. */
|
||||
async function getActiveRelays(): Promise<string[]> {
|
||||
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 };
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue