Fix firehose

This commit is contained in:
Alex Gleason 2025-03-08 21:03:36 -06:00
parent 6b3f5ac8a6
commit 026568ea71
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 12 additions and 5 deletions

View file

@ -6,7 +6,8 @@ import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
import { DittoPool } from './DittoPool.ts'; import { DittoPool } from './DittoPool.ts';
Deno.test('DittoPool.reqRouter', async (t) => { Deno.test('DittoPool.reqRouter', async (t) => {
const conf = new DittoConf(new Map([['DITTO_NSEC', nip19.nsecEncode(generateSecretKey())]])); const nsec = generateSecretKey();
const conf = new DittoConf(new Map([['DITTO_NSEC', nip19.nsecEncode(nsec)]]));
const relay = new MockRelay(); const relay = new MockRelay();
const pool = new DittoPool({ conf, relay }); const pool = new DittoPool({ conf, relay });
@ -58,6 +59,16 @@ Deno.test('DittoPool.reqRouter', async (t) => {
assertEquals(reqRoutes, expected); assertEquals(reqRoutes, expected);
}); });
await t.step('no authors with fallback', async () => {
const fallback = genEvent({ kind: 10002, tags: [['r', ditto]] }, nsec);
await relay.event(fallback);
const reqRoutes = await pool.reqRouter([{ kinds: [1] }]);
const expected = new Map([[ditto, [{ kinds: [1] }]]]);
assertEquals(reqRoutes, expected);
});
}); });
function generateKeypair(): { pk: string; sk: Uint8Array } { function generateKeypair(): { pk: string; sk: Uint8Array } {

View file

@ -47,10 +47,6 @@ export class DittoPool extends NPool<NRelay1> {
} }
} }
if (!authors.size) {
return routes;
}
const pubkey = await conf.signer.getPublicKey(); const pubkey = await conf.signer.getPublicKey();
const map = new Map<string, NostrEvent>(); const map = new Map<string, NostrEvent>();