Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
fix: PoW 算法错误 (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlgzs authored May 23, 2023
1 parent 56d18fd commit 726958d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/core/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,14 +938,14 @@ function calcPoW(this: BaseClient, data: any) {
if (typ === 2 && tgt.length === 32) {
let tmp = BigInt("0x" + src.toString("hex"));
const start = Date.now()
let hash = createHash("sha256").update(Buffer.from(tmp.toString(16), "hex")).digest()
let hash = createHash("sha256").update(Buffer.from(tmp.toString(16).padStart(256, "0"), "hex")).digest()
while (Buffer.compare(hash, tgt)) {
tmp++
hash = createHash("sha256").update(Buffer.from(tmp.toString(16), "hex")).digest()
hash = createHash("sha256").update(Buffer.from(tmp.toString(16).padStart(256, "0"), "hex")).digest()
cnt++
}
ok = true
dst = Buffer.from(tmp.toString(16), "hex")
dst = Buffer.from(tmp.toString(16).padStart(256, "0"), "hex")
elp = Date.now() - start
}
const writer = new Writer()
Expand Down

0 comments on commit 726958d

Please sign in to comment.