Merge branch 'pool-log' into 'main'
Pool: log number of active relays to connect to See merge request soapbox-pub/ditto!76
This commit is contained in:
commit
eec8432d50
|
@ -1,5 +1,5 @@
|
||||||
import { type Event } from '@/deps.ts';
|
import { type Event } from '@/deps.ts';
|
||||||
import { allRelays, pool } from '@/pool.ts';
|
import { activeRelays, pool } from '@/pool.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '@/utils.ts';
|
||||||
|
|
||||||
import * as pipeline from './pipeline.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.
|
// and storing events for notifications and the home feed.
|
||||||
pool.subscribe(
|
pool.subscribe(
|
||||||
[{ kinds: [0, 1, 3, 5, 6, 7, 10002], limit: 0, since: nostrNow() }],
|
[{ kinds: [0, 1, 3, 5, 6, 7, 10002], limit: 0, since: nostrNow() }],
|
||||||
allRelays,
|
activeRelays,
|
||||||
handleEvent,
|
handleEvent,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
|
10
src/pool.ts
10
src/pool.ts
|
@ -1,9 +1,11 @@
|
||||||
import { getActiveRelays } from '@/db/relays.ts';
|
import { getActiveRelays } from '@/db/relays.ts';
|
||||||
import { type Event, RelayPool } from '@/deps.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.
|
// The pipeline verifies events.
|
||||||
skipVerification: true,
|
skipVerification: true,
|
||||||
// The logging feature overwhelms the CPU and creates too many logs.
|
// 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. */
|
/** 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);
|
return pool.publish(event, relays);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { allRelays, pool, publish };
|
export { activeRelays, pool, publish };
|
||||||
|
|
Loading…
Reference in New Issue