console.log('%cSCORING COMPLETE', 'color:orange;font-weight:bold')
}
+ async function execute (size, difficulty, effort, api, isOutputShown, isDebug) {
+ Cache.clear()
+ const output = document.getElementById('output')
+ 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}`)
+ hash = random()
+ start = performance.now()
+ result = await NanoPow.work_generate(hash, { difficulty, effort, api })
+ end = performance.now()
+ times.push(end - start)
+ 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/>'
+ if (!isValid) console.log(hash, result, check)
+ }
+ }
+ return times
+ }
+
function startValidation (event) {
const difficulty = document.getElementById('difficulty')?.value
const work = document.getElementById('work')?.value