POW everything

This commit is contained in:
2023-08-18 17:56:50 +01:00
parent 2a851c442d
commit 1c5e61e020
7 changed files with 49 additions and 24 deletions

View File

@ -1,17 +1,9 @@
import { ExternalStore, dedupe } from "@snort/shared";
import {
EventKind,
NostrPrefix,
encodeTLVEntries,
TLVEntryType,
TLVEntry,
decodeTLV,
PowWorker,
NostrEvent,
} from "@snort/system";
import { EventKind, NostrPrefix, encodeTLVEntries, TLVEntryType, TLVEntry, decodeTLV, NostrEvent } from "@snort/system";
import { GiftWrapCache } from "Cache/GiftWrapCache";
import { UnwrappedGift } from "Db";
import { Chat, ChatSystem, ChatType, lastReadInChat } from "chat";
import { DefaultPowWorker } from "index";
export class Nip24ChatSystem extends ExternalStore<Array<Chat>> implements ChatSystem {
#cache: GiftWrapCache;
@ -107,17 +99,10 @@ export class Nip24ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
const messages: Array<Promise<NostrEvent>> = [];
const powTarget = 4 * 4; // 4-char zero
for (const pt of participants) {
const recvSealedN = pub.giftWrap(
await pub.sealRumor(gossip, pt.id),
pt.id,
powTarget,
new PowWorker("/pow.js")
);
const recvSealedN = pub.giftWrap(await pub.sealRumor(gossip, pt.id), pt.id, powTarget);
messages.push(recvSealedN);
}
messages.push(
pub.giftWrap(await pub.sealRumor(gossip, pub.pubKey), pub.pubKey, powTarget, new PowWorker("/pow.js"))
);
messages.push(pub.giftWrap(await pub.sealRumor(gossip, pub.pubKey), pub.pubKey, powTarget, DefaultPowWorker));
return await Promise.all(messages);
},
sendMessage: (ev, system) => {