}
}
- export async function run (size, effort, isOutputShown, isGlForced, isDebug) {
+ export async function run (threshold, size, effort, isOutputShown, isGlForced, isDebug) {
if (isGlForced) NanoPow = NanoPowGl
document.getElementById('status').innerHTML = `TESTING IN PROGRESS 0/${size}`
console.log(`%cNanoPow`, 'color:green', 'Checking validate()')
let work = null
const start = performance.now()
try {
- work = await NanoPow.search(hash, { threshold: 0, effort, debug: isDebug })
+ work = await NanoPow.search(hash, { threshold, effort, debug: isDebug })
} catch (err) {
document.getElementById('output').innerHTML += `Error: ${err.message}<br/>`
console.error(err)
+ return
}
const end = performance.now()
- // const isValid = (await NanoPow.validate(work, hash, { threshold: 0 })) ? 'VALID' : 'INVALID'
- const isValid = 'Valid'
+ const isValid = (await NanoPow.validate(work, hash, { threshold: 0 })) ? 'VALID' : 'INVALID'
times.push(end - start)
const msg = `${isValid} [${work}] ${hash} (${end - start} ms)`
- // console.log(msg)
if (isOutputShown) document.getElementById('output').innerHTML += `${msg}<br/>`
}
document.getElementById('output').innerHTML += `<hr/>`
}
function startValidation (event) {
+ const threshold = document.getElementById('threshold')
const work = document.getElementById('work')
const hash = document.getElementById('hash')
const validation = document.getElementById('validation')
validation.innerText = ''
- NanoPow.validate(work.value, hash.value)
+ NanoPow.validate(work.value, hash.value, { threshold: `0x${+threshold.value}` })
.then(result => {
validation.innerText = result
? 'Valid'
document.getElementById('btnStartValidation').addEventListener('click', startValidation)
function startTest (event) {
+ const threshold = document.getElementById('threshold')
const size = document.getElementById('size')
const effort = document.getElementById('effort')
const isOutputShown = document.getElementById('isOutputShown')
const isGlForced = document.getElementById('isGlForced')
const isDebug = document.getElementById('isDebug')
- run(+size.value, +effort.value, isOutputShown.checked, isGlForced.checked, isDebug.checked)
+ run(+`0x${threshold.value}`, +size.value, +effort.value, isOutputShown.checked, isGlForced.checked, isDebug.checked)
}
document.getElementById('btnStartTest').addEventListener('click', startTest)
</script>
<p>Times below are in milliseconds and are summarized by various averaging methods.</p>
<p>Level of Effort depends on hardware and does not guarantee faster results.</p>
<hr />
+ <label for="threshold">Threshold 0x</label>
+ <input id="threshold" type="text" value="FFFFFFF8" />
+ <hr/>
<label for="work">Work</label>
<input id="work" type="text" />
<label for="hash">Hash</label>
<span id="validation"></span>
<hr />
<label for="size">Test Size</label>
- <input id="size" type="number" value="1" autofocus />
+ <input id="size" type="number" value="64" autofocus />
<label for="effort">Effort (1-32)</label>
<input id="effort" type="number" value="8" min="1" max="32" />
<span>