Pool: log number of active relays to connect to

This commit is contained in:
Alex Gleason 2023-12-17 11:00:04 -06:00
parent ddf1fce2b6
commit cdfb21caa6
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { type Event } from '@/deps.ts';
import { allRelays, pool } from '@/pool.ts';
import { activeRelays, pool } from '@/pool.ts';
import { nostrNow } from '@/utils.ts';
import * as pipeline from './pipeline.ts';
@ -9,7 +9,7 @@ import * as pipeline from './pipeline.ts';
// and storing events for notifications and the home feed.
pool.subscribe(
[{ kinds: [0, 1, 3, 5, 6, 7, 10002], limit: 0, since: nostrNow() }],
allRelays,
activeRelays,
handleEvent,
undefined,
undefined,

View File

@ -1,9 +1,11 @@
import { getActiveRelays } from '@/db/relays.ts';
import { type Event, RelayPool } from '@/deps.ts';
const allRelays = await getActiveRelays();
const activeRelays = await getActiveRelays();
const pool = new RelayPool(allRelays, {
console.log(`pool: connecting to ${activeRelays.length} relays.`);
const pool = new RelayPool(activeRelays, {
// The pipeline verifies events.
skipVerification: true,
// The logging feature overwhelms the CPU and creates too many logs.
@ -11,8 +13,8 @@ const pool = new RelayPool(allRelays, {
});
/** Publish an event to the given relays, or the entire pool. */
function publish(event: Event, relays: string[] = allRelays) {
function publish(event: Event, relays: string[] = activeRelays) {
return pool.publish(event, relays);
}
export { allRelays, pool, publish };
export { activeRelays, pool, publish };