]> zoso.dev Git - libnemo.git/commitdiff
Calculate block hash directly instead of calling Tools.
authorChris Duncan <chris@zoso.dev>
Mon, 2 Dec 2024 19:48:10 +0000 (11:48 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 2 Dec 2024 19:48:10 +0000 (11:48 -0800)
src/lib/block.ts

index 71a25cd37c84b29f46cae65986c8713756b2d674..273d72099755ca05d2093adaeabe68752581a233 100644 (file)
@@ -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()
        }
 
        /**