Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function mine() {
let duration = 0
let startTime = (new Date()).getTime()
let batchDiff = 0
let finished = false
let hash
for (let i = 0; i < batchSize; i++) {
let block = headerIntArr.concat(nonceToByteArray(nonce))
hash = sha256.update(block)
hash = sha256.update(hash.digest())
if (isHashLessThanTarget(hash.hex())) {
console.log('submit hash:', hash.hex())
console.log('target:', target.toString(16))
submitWork(work, nonce)
}
if (nonce >= 0xFFFFFFFF) {
batchDiff = batchSize - i + 1
finished = true
break;
} else {
nonce++
}
}
duration = (new Date()).getTime() - startTime
function mine() {
let duration = 0
let startTime = (new Date()).getTime()
let batchDiff = 0
let finished = false
let hash
for (let i = 0; i < batchSize; i++) {
let block = headerIntArr.concat(nonceToByteArray(nonce))
hash = sha256.update(block)
hash = sha256.update(hash.digest())
if (isHashLessThanTarget(hash.hex())) {
console.log('submit hash:', hash.hex())
console.log('target:', target.toString(16))
submitWork(work, nonce)
}
if (nonce >= 0xFFFFFFFF) {
batchDiff = batchSize - i + 1
finished = true
break;
} else {
nonce++
}
}