Move pool to a separate module (to avoid importing firehose in tests)
This commit is contained in:
parent
f2ccb5254e
commit
17c75e6761
|
@ -1,18 +1,15 @@
|
|||
import { getActiveRelays } from '@/db/relays.ts';
|
||||
import { type Event, RelayPool } from '@/deps.ts';
|
||||
import { type Event } from '@/deps.ts';
|
||||
import { allRelays, pool } from '@/pool.ts';
|
||||
import { nostrNow } from '@/utils.ts';
|
||||
|
||||
import * as pipeline from './pipeline.ts';
|
||||
|
||||
const _relays = await getActiveRelays();
|
||||
const pool = new RelayPool(_relays);
|
||||
|
||||
// This file watches events on all known relays and performs
|
||||
// side-effects based on them, such as trending hashtag tracking
|
||||
// and storing events for notifications and the home feed.
|
||||
pool.subscribe(
|
||||
[{ kinds: [0, 1, 3, 5, 6, 7, 10002], limit: 0, since: nostrNow() }],
|
||||
_relays,
|
||||
allRelays,
|
||||
handleEvent,
|
||||
undefined,
|
||||
undefined,
|
||||
|
@ -26,10 +23,3 @@ function handleEvent(event: Event): Promise<void> {
|
|||
.handleEvent(event)
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
/** Publish an event to the given relays, or the entire pool. */
|
||||
function publish(event: Event, relays: string[] = _relays) {
|
||||
return pool.publish(event, relays);
|
||||
}
|
||||
|
||||
export { publish };
|
||||
|
|
|
@ -3,9 +3,9 @@ import * as eventsDB from '@/db/events.ts';
|
|||
import { addRelays } from '@/db/relays.ts';
|
||||
import { findUser } from '@/db/users.ts';
|
||||
import { type Event, LRUCache } from '@/deps.ts';
|
||||
import { publish } from '@/firehose.ts';
|
||||
import { isEphemeralKind } from '@/kinds.ts';
|
||||
import * as mixer from '@/mixer.ts';
|
||||
import { publish } from '@/pool.ts';
|
||||
import { isLocallyFollowed } from '@/queries.ts';
|
||||
import { Sub } from '@/subs.ts';
|
||||
import { getTagSet } from '@/tags.ts';
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import { getActiveRelays } from '@/db/relays.ts';
|
||||
import { type Event, RelayPool } from '@/deps.ts';
|
||||
|
||||
const allRelays = await getActiveRelays();
|
||||
const pool = new RelayPool(allRelays);
|
||||
|
||||
/** Publish an event to the given relays, or the entire pool. */
|
||||
function publish(event: Event, relays: string[] = allRelays) {
|
||||
return pool.publish(event, relays);
|
||||
}
|
||||
|
||||
export { allRelays, pool, publish };
|
Loading…
Reference in New Issue