mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-25 01:04:25 +01:00
Use only "active" relays in the pool
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user