Pool: log number of active relays to connect to
This commit is contained in:
parent
ddf1fce2b6
commit
cdfb21caa6
|
@ -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,
|
||||
|
|
10
src/pool.ts
10
src/pool.ts
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue