コード例 #1
0
ファイル: client.js プロジェクト: EthereumBR/ethpoolbr
	// calculate target difficulty for this client
	// heavily inspired by https://github.com/ming08108/EtherPool (shareHandler.js)
	calculateTarget(work, secpershare) {
		if ((this.mhs == this._lastmhs) && (this._secpershare == secpershare)) {
			// return cached target to avoid recalculation
			return this._target;
		}

		// get desired number of seconds between shares
		var sec = new BN(secpershare);
		// calculate hashes per second
		var hs = new BN(this.mhs * 1000).mul(new BN(1000));
		// total number of hashes before finding solution
		var th = sec.mul(hs);
		// calculate target for worker
		var target = ethUtil.TWO_POW256.div(th);
		// update cached values
		this._lastmhs = this.mhs;
		this._secpershare = secpershare;
		this._target = '0x' + target.toString(16, 64);
		this._diff = th.toString();

		logger.debug('New target for %s', this.wallet);
		logger.debug('  Current calculated MHS: %s MH/s', this.mhs);

		return this._target;
	}
コード例 #2
0
ファイル: opFns.js プロジェクト: jedygabriel/GDG
 NOT: function (runState) {
   runState.stack.push(
     new Buffer(utils.TWO_POW256.subn(1).sub(new BN(runState.stack.pop()))
       .toArray())
   )
 },