Skip to content

Commit 14bd7bf

Browse files
committed
xcore-0.9.8b
- added handlers to SignerPowMiner for external hashing
1 parent 5880aad commit 14bd7bf

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

Meta/CoreConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CoreConfig
2626
/// <summary>
2727
/// Current version of IxiCore.
2828
/// </summary>
29-
public static readonly string version = "xcore-0.9.8a";
29+
public static readonly string version = "xcore-0.9.8b";
3030

3131
/// <summary>
3232
/// Current version of the Ixian network protocol.

Miner/SignerPowMiner.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2017-2025 Ixian
1+
// Copyright (C) 2017-2026 Ixian
22
// This file is part of Ixian Core - www.github.com/ixian-platform/Ixian-Core
33
//
44
// Ixian Core is free software: you can redistribute it and/or modify
@@ -463,5 +463,46 @@ public IEnumerable<SignerPowSolution> GetSolutions(ulong fromBlockHeight, ulong
463463
{
464464
return GetSolutions(fromBlockHeight, toBlockHeight).OrderByDescending(x => x.difficulty).FirstOrDefault();
465465
}
466+
467+
public (byte[] challenge, IxiNumber minDifficulty, ulong blockHeight) GetChallenge()
468+
{
469+
if (currentBlockHeight == 0)
470+
{
471+
return (null, 0, 0);
472+
}
473+
474+
var lastSolution = solutions.Values.OrderByDescending(x => x.blockNum).FirstOrDefault();
475+
if (lastSolution != null)
476+
{
477+
return (PrepareChallenge(lastSolution.blockNum, IxianHandler.getBlockHash(lastSolution.blockNum), lastSolution.keyPair, Array.Empty<byte>()), solvingDifficulty, lastSolution.blockNum);
478+
}
479+
return (null, 0, 0);
480+
}
481+
482+
public IxiNumber ProcessExternalSolution(ulong blockHeight, byte[] nonce)
483+
{
484+
if (nonce == null || nonce.Length <= 1)
485+
{
486+
return 0;
487+
}
488+
489+
if (!solutions.TryGetValue(blockHeight, out var solution))
490+
{
491+
return 0;
492+
}
493+
494+
byte[] challengeWithNonce = PrepareChallenge(blockHeight, IxianHandler.getBlockHash(blockHeight), solution.keyPair, nonce);
495+
byte[] hash = CryptoManager.lib.sha3_512sq(challengeWithNonce);
496+
var status = ProcessSolution(hash, challengeWithNonce, nonce.Length, solvingDifficulty, solution.blockNum, solution.keyPair);
497+
498+
if (status.solution != null
499+
&& blockHeight > lastFoundBlockHeight)
500+
{
501+
lastFoundBlockHeight = blockHeight;
502+
}
503+
504+
return status.difficulty;
505+
}
506+
466507
}
467508
}

0 commit comments

Comments
 (0)