}
async function init (hash: bigint, difficulty: bigint, effort: number): Promise<void> {
- data.hash = bigHex(hash)
- data.difficulty = bigHex(difficulty)
+ data.hash = bigHex(hash, 64)
+ data.difficulty = bigHex(difficulty, 16)
for (let i = workers.length; i < effort; i++) {
workers.push(new Worker(url, { type: 'module' }))
const seed = crypto.getRandomValues(new BigUint64Array(workers.length))
const attempts = []
for (let i = 0; i < workers.length; i++) {
- data.seed = bigHex(seed[i])
+ data.seed = bigHex(seed[i], 16)
attempts.push(new Promise((found, err) => {
const w = workers[i]
w.onerror = err
w.onmessage = (msg) => {
const { data } = msg
if (data.url === url) {
- LOG: logger.log(`received result ${data.result} from worker ${i}`)
+ LOG: logger.log(`received result ${typeof data.result} "${data.result}" from worker ${i}`)
found(data.result)
}
}