Add PowWorker to mine Nostr events off the main thread

This commit is contained in:
Alex Gleason
2023-11-20 15:38:05 -06:00
parent f7aff70185
commit d293c9d900
4 changed files with 25 additions and 0 deletions

10
src/workers/pow.worker.ts Normal file
View File

@ -0,0 +1,10 @@
import * as Comlink from 'comlink';
import { nip13, type UnsignedEvent } from 'nostr-tools';
export const PowWorker = {
mine<K extends number>(event: UnsignedEvent<K>, difficulty: number) {
return nip13.minePow(event, difficulty);
},
};
Comlink.expose(PowWorker);