feat: negentropy

This commit is contained in:
2024-01-25 15:21:42 +00:00
parent 9a0bbb8b74
commit d7460651c8
31 changed files with 924 additions and 266 deletions

View File

@ -112,9 +112,17 @@ globalThis.onmessage = async ev => {
await barrierQueue(cmdQueue, async () => {
const req = msg.args as ReqCommand;
const filters = req.slice(2) as Array<ReqFilter>;
const results = [];
const results: Array<string | NostrEvent> = [];
const ids = new Set<string>();
for (const r of filters) {
results.push(...relay!.req(req[1], r));
const rx = relay!.req(req[1], r);
for (const x of rx) {
if ((typeof x === "string" && ids.has(x)) || ids.has((x as NostrEvent).id)) {
continue;
}
ids.add(typeof x === "string" ? x : (x as NostrEvent).id);
results.push(x);
}
}
reply(msg.id, results);
});