From: Chris Duncan Date: Mon, 2 Dec 2024 19:48:10 +0000 (-0800) Subject: Calculate block hash directly instead of calling Tools. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=a202d681b5badd9dd83d7fe67bbbc14a897111c7;p=libnemo.git Calculate block hash directly instead of calling Tools. --- diff --git a/src/lib/block.ts b/src/lib/block.ts index 71a25cd..273d720 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -3,6 +3,7 @@ import { BURN_ADDRESS, PREAMBLE } from './constants.js' import { Account } from './account.js' +import { Blake2b } from './blake2b.js' import { bytes, dec, hex } from './convert.js' import { NanoNaCl } from './nano-nacl.js' import { Pool } from './pool.js' @@ -73,8 +74,9 @@ abstract class Block { dec.toHex(this.balance, 32), this.link ] - const hash = await Tools.hash(data, 'hex') - return hash + const hash = new Blake2b(32) + data.forEach(str => hash.update(hex.toBytes(str))) + return hash.digest('hex').toUpperCase() } /**