]> git.codecow.com Git - nano-pow.git/commitdiff
Fix execution output updates and provide default arg values.
authorChris Duncan <chris@codecow.com>
Fri, 22 May 2026 19:54:33 +0000 (12:54 -0700)
committerChris Duncan <chris@codecow.com>
Fri, 22 May 2026 19:54:33 +0000 (12:54 -0700)
test/index.html

index d3ef3bba54743fb132e5223199958f805bba9470..2a17bc78c1e14b9b3de2dfd4dbad5133172d4492 100644 (file)
@@ -239,13 +239,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
                        console.log('%cSCORING COMPLETE', 'color:orange;font-weight:bold')
                }
 
-               async function execute (size, difficulty, effort, api, isOutputShown, isDebug) {
+               async function execute (size, difficulty, effort, api, isOutputShown = false, isDebug = false) {
                        Cache.clear()
                        const output = document.getElementById('output')
+                       const status = document.getElementById('status')
                        const times = []
                        let hash, result, start, end, check, isValid
                        for (let i = 0; i < size; i++) {
-                               document.getElementById('status').textContent.replace(`${(i || 1) - 1}/${size}`, `${i}/${size}`)
+                               status.textContent = status.textContent.replace(`${(i || 1) - 1}/${size}`, `${i}/${size}`)
                                hash = random()
                                start = performance.now()
                                result = await NanoPow.work_generate(hash, { difficulty, effort, api })
@@ -254,8 +255,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
                                check = await NanoPow.work_validate(result.work, result.hash, { difficulty, debug: isDebug })
                                isValid = (result.hash === hash && check.hash === hash && check.valid === '1')
                                if (isOutputShown) {
-                                       output.textContent += `${isValid ? 'VALID' : 'INVALID'} (${end - start} ms)\n${JSON.stringify(result, ' ', 2)}`
-                                       output.innerHTML += '<br/>'
+                                       output.textContent += `${isValid ? 'VALID' : 'INVALID'} (${end - start} ms)\n${JSON.stringify(result, ' ', 2)}\n`
                                        if (!isValid) console.log(hash, result, check)
                                }
                        }