]> zoso.dev Git - libnemo.git/commitdiff
Move threshold constants into CONSTANTS and use them in block pow.
authorChris Duncan <chris@zoso.dev>
Tue, 3 Dec 2024 21:21:59 +0000 (13:21 -0800)
committerChris Duncan <chris@zoso.dev>
Tue, 3 Dec 2024 21:21:59 +0000 (13:21 -0800)
src/lib/block.ts
src/lib/constants.ts
src/lib/pow.ts

index 1e409f9acba0d9683aad76ca6dd1329b26851738..691ec1fef9650e574da28ff1728970eea6040efe 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-FileCopyrightText: 2024 Chris Duncan <chris@zoso.dev>
 // SPDX-License-Identifier: GPL-3.0-or-later
 
-import { BURN_ADDRESS, PREAMBLE } from './constants.js'
+import { BURN_ADDRESS, PREAMBLE, THRESHOLD_RECEIVE, THRESHOLD_SEND } from './constants.js'
 import { Account } from './account.js'
 import { Blake2b } from './blake2b.js'
 import { bytes, dec, hex } from './convert.js'
@@ -84,7 +84,10 @@ abstract class Block {
        async pow (): Promise<void> {
                const pool = new Pool(Pow)
                const data = {
-                       "hash": this.previous
+                       "hash": this.previous,
+                       "threshold": (this instanceof SendBlock || this instanceof ChangeBlock)
+                               ? THRESHOLD_SEND
+                               : THRESHOLD_RECEIVE
                }
                const [{ work }] = await pool.work('converge', [data])
                this.work = work
index f74636403d930ce904ad2bf8125c7859d06c3450..16a7f01cf926707c6036c1b01b4f136b138903c6 100644 (file)
@@ -16,6 +16,8 @@ export const PREFIX_LEGACY = 'xrb_'
 export const SEED_LENGTH_BIP44 = 128
 export const SEED_LENGTH_BLAKE2B = 64
 export const SLIP10_ED25519 = 'ed25519 seed'
+export const THRESHOLD_RECEIVE = '0xfffffe'
+export const THRESHOLD_SEND = '0xfffffff8'
 export const XNO = 'ΣΎ'
 
 export const LEDGER_STATUS_CODES: { [key: number]: string } = Object.freeze({
index 1c67600eacf4154e756867133a799460e6fa180a..5f8485ce3d5356206f9120d0e3de4b3bada8c1c9 100644 (file)
@@ -4,10 +4,7 @@
 import { Blake2b } from './blake2b.js'
 
 const p = () => {
-       const NONCE_BYTES = 8
-       const RECEIVE_THRESHOLD = '0xfffffe'
        const SEND_THRESHOLD = '0xfffffff8'
-
        /**
        * Listens for messages from a calling function.
        */