Monero Job fix
@@ -30,7 +30,6 @@ using MiningCore.Extensions;
using MiningCore.Native;
using MiningCore.Stratum;
using MiningCore.Util;
-using NBitcoin;
using NBitcoin.BouncyCastle.Math;
using Contract = MiningCore.Contracts.Contract;
@@ -59,7 +58,6 @@ namespace MiningCore.Blockchain.Monero
}
BlockTemplate = blockTemplate;
- ComputeBlockTarget();
PrepareBlobTemplate(instanceId);
}
@@ -67,7 +65,6 @@ namespace MiningCore.Blockchain.Monero
private byte[] blobTemplate;
private uint extraNonce;
- private uint256 blockTarget;
private void PrepareBlobTemplate(byte[] instanceId)
{
@@ -94,29 +91,10 @@ namespace MiningCore.Blockchain.Monero
}
}
- private void ComputeBlockTarget()
- {
- if (BlockTemplate.Difficulty != 1)
- {
- var diff = BigInteger.ValueOf((long) (BlockTemplate.Difficulty * 255d));
- var quotient = MoneroConstants.Diff1.Divide(diff).Multiply(BigInteger.ValueOf(255));
- var bytes = quotient.ToByteArray();
- var padded = Enumerable.Repeat((byte) 0, 32).ToArray();
-
- if (padded.Length - bytes.Length > 0)
- Buffer.BlockCopy(bytes, 0, padded, padded.Length - bytes.Length, bytes.Length);
-
- blockTarget = new uint256(padded);
- }
-
- else
- blockTarget = MoneroConstants.Diff1c;
- }
-
private string EncodeTarget(double difficulty)
{
- var diff = BigInteger.ValueOf((long)difficulty);
- var quotient = MoneroConstants.Diff1.Divide(diff);
+ var diff = BigInteger.ValueOf((long)(difficulty * 255d));
+ var quotient = MoneroConstants.Diff1.Divide(diff).Multiply(BigInteger.ValueOf(255));
var bytes = quotient.ToByteArray();
var padded = Enumerable.Repeat((byte)0, 32).ToArray();
@@ -199,9 +177,7 @@ namespace MiningCore.Blockchain.Monero
var shareDiff = (double)new BigRational(MoneroConstants.Diff1b, headerValue);
var stratumDifficulty = context.Difficulty;
var ratio = shareDiff / stratumDifficulty;
- var isBlockCandidate = headerValue <= blockTarget;
-
-//Console.WriteLine("{0:F2} - {1:F2}", shareDiff, BlockTemplate.Difficulty);
+ var isBlockCandidate = shareDiff >= BlockTemplate.Difficulty;
// test if share meets at least workers current difficulty
if (!isBlockCandidate && ratio < 0.99)
