From a202d681b5badd9dd83d7fe67bbbc14a897111c7 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 2 Dec 2024 11:48:10 -0800 Subject: [PATCH] Calculate block hash directly instead of calling Tools. --- src/lib/block.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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() } /** -- 2.34.1