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();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a list of all known good relays. */
|
/** Get a list of all known active relay URLs. */
|
||||||
async function getAllRelays(): Promise<string[]> {
|
async function getActiveRelays(): Promise<string[]> {
|
||||||
const rows = await db
|
const rows = await db
|
||||||
.selectFrom('relays')
|
.selectFrom('relays')
|
||||||
.select('relays.url')
|
.select('relays.url')
|
||||||
|
.where('relays.active', '=', true)
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
return rows.map((row) => row.url);
|
return rows.map((row) => row.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { addRelays, getAllRelays };
|
export { addRelays, getActiveRelays };
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { insertEvent, isLocallyFollowed } from '@/db/events.ts';
|
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 { findUser } from '@/db/users.ts';
|
||||||
import { RelayPool } from '@/deps.ts';
|
import { RelayPool } from '@/deps.ts';
|
||||||
import { trends } from '@/trends.ts';
|
import { trends } from '@/trends.ts';
|
||||||
|
@ -7,7 +7,7 @@ import { isRelay, nostrDate, nostrNow } from '@/utils.ts';
|
||||||
|
|
||||||
import type { SignedEvent } from '@/event.ts';
|
import type { SignedEvent } from '@/event.ts';
|
||||||
|
|
||||||
const relays = await getAllRelays();
|
const relays = await getActiveRelays();
|
||||||
const pool = new RelayPool(relays);
|
const pool = new RelayPool(relays);
|
||||||
|
|
||||||
// This file watches events on all known relays and performs
|
// This file watches events on all known relays and performs
|
||||||
|
|
Loading…
Reference in New Issue