Rework client as EventStore

This commit is contained in:
Alex Gleason
2023-12-29 13:22:51 -06:00
parent e6c8d1dad9
commit ccfdbfeb8d
6 changed files with 42 additions and 29 deletions

View File

@@ -1,7 +1,5 @@
import { getActiveRelays } from '@/db/relays.ts';
import { Debug, type Event, RelayPoolWorker } from '@/deps.ts';
const debug = Debug('ditto:pool');
import { RelayPoolWorker } from '@/deps.ts';
const activeRelays = await getActiveRelays();
@@ -17,10 +15,4 @@ const pool = new RelayPoolWorker(worker, activeRelays, {
logErrorsAndNotices: false,
});
/** Publish an event to the given relays, or the entire pool. */
function publish(event: Event, relays: string[] = activeRelays) {
debug('publish', event);
return pool.publish(event, relays);
}
export { activeRelays, pool, publish };
export { activeRelays, pool };