Better POW UX

This commit is contained in:
2023-08-18 19:01:34 +01:00
parent 1c5e61e020
commit a5be4da2e8
4 changed files with 78 additions and 28 deletions

View File

@ -22,6 +22,7 @@ export * from "./zaps";
export * from "./signer";
export * from "./text";
export * from "./pow";
export * from "./pow-util";
export * from "./impl/nip4";
export * from "./impl/nip44";

View File

@ -30,7 +30,7 @@ export function minePow(e: NostrPowEvent, target: number) {
e.tags[nonceTagIdx][1] = (++ctr).toString();
e.id = createId(e);
} while (countLeadingZeroes(e.id) < target);
} while (countLeadingZeros(e.id) < target);
return e;
}
@ -40,7 +40,7 @@ function createId(e: NostrPowEvent) {
return bytesToHex(sha256(JSON.stringify(payload)));
}
function countLeadingZeroes(hex: string) {
export function countLeadingZeros(hex: string) {
let count = 0;
for (let i = 0; i < hex.length; i++) {