Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
estimateRewardPerHour() {
if (!this.wrappedMiner) {
this.theWrapper.callbacks.error("MinerHelper:estimateRewardPerHour", NimiqWrapper.ERROR_MESSAGES.NO_MINER_YET);
return;
}
let myHash = this.wrappedMiner.hashrate;
let goHash = this.theWrapper.globalHashrate;
let reward = Nimiq.Policy.lunasToCoins(Nimiq.Policy.blockRewardAt(this.theWrapper.blockHeight));
let perBlock = (myHash / goHash) * reward;
return perBlock * (60 / 1); //1 block per minute, 60 minutes in an hour.
}get globalHashrate() {
const nBits = this.wrappedNode.blockchain.head.header.nBits;
const difficulty = Nimiq.BlockUtils.compactToDifficulty(nBits);
return difficulty * Math.pow(2, 16) / Nimiq.Policy.BLOCK_TIME;
}convertNIMToLuna(value) {
return Nimiq.Policy.coinsToLunas(value);
}