Permalink
Browse files

Add OOTB support for LBRY, Lyra2REv2 and Nist5 algorithms

  • Loading branch information...
nwoolls committed Feb 4, 2018
1 parent 3d488fc commit 170f5e44c606c52669a2edd6702ce26a3baa25d5
@@ -56,6 +56,7 @@
<ItemGroup>
<Compile Include="InstallerTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringExtensionsTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MultiMiner.Engine\MultiMiner.Engine.csproj">
@@ -0,0 +1,88 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MultiMiner.Engine.Extensions;
namespace MultiMiner.Engine.Tests
{
[TestClass]
public class StringExtensionsTests
{
[TestMethod]
public void ToSpaceDelimitedWords_WithOneHour_Returns_One_Hour()
{
// arrange
var unformattedText = "OneHour";
// act
var formattedText = unformattedText.ToSpaceDelimitedWords();
// assert
Assert.AreEqual("One Hour", formattedText);
}
[TestMethod]
public void ToSpaceDelimitedWords_WithTwentyFourHours_Returns_Twenty_Four_Hours()
{
// arrange
var unformattedText = "TwentyFourHours";
// act
var formattedText = unformattedText.ToSpaceDelimitedWords();
// assert
Assert.AreEqual("Twenty Four Hours", formattedText);
}
[TestMethod]
public void ToSpaceDelimitedWords_WithNeoScrypt_Returns_Neo_Scrypt()
{
// arrange
var unformattedText = "NeoScrypt";
// act
var formattedText = unformattedText.ToSpaceDelimitedWords();
// assert
Assert.AreEqual("Neo Scrypt", formattedText);
}
[TestMethod]
public void ToSpaceDelimitedWords_WithLyra2REv2_Returns_Lyra2RE_v2()
{
// arrange
var unformattedText = "Lyra2REv2";
// act
var formattedText = unformattedText.ToSpaceDelimitedWords();
// assert
Assert.AreEqual("Lyra2REv2", formattedText);
}
[TestMethod]
public void ToSpaceDelimitedWords_WithLyra2RE_Returns_Lyra2RE_v2()
{
// arrange
var unformattedText = "Lyra2RE";
// act
var formattedText = unformattedText.ToSpaceDelimitedWords();
// assert
Assert.AreEqual("Lyra2RE", formattedText);
}
[TestMethod]
public void ToSpaceDelimitedWords_WithBlake256r8_Returns_Lyra2RE_v2()
{
// arrange
var unformattedText = "Blake256r8";
// act
var formattedText = unformattedText.ToSpaceDelimitedWords();
// assert
Assert.AreEqual("Blake256r8", formattedText);
}
}
}
@@ -18,5 +18,8 @@ class AlgorithmParameter
public const string AlgorithmCryptoNight = "--algorithm cryptonight";
public const string AlgorithmEquihash = "--algorithm equihash";
public const string AlgorithmPascal = "--algorithm pascal";
public const string AlgorithmLbry = "--algorithm lbry";
public const string AlgorithmLyra2REv2 = "--algorithm lyra2rev2";
public const string AlgorithmNist5 = "--algorithm nist5";
}
}
@@ -13,5 +13,6 @@ public class MinerNames
public const string MaxcoinCGMiner = "MaxcoinCGMiner";
public const string SGMinerGM = "SGMinerGM";
public const string SGMinerPascal = "SGMinerPascal";
public const string SGMinerNH = "SGMinerNH";
}
}
@@ -1,12 +1,33 @@
using System.Text.RegularExpressions;
namespace MultiMiner.Engine.Extensions
namespace MultiMiner.Engine.Extensions
{
public static class StringExtensions
{
public static string ToSpaceDelimitedWords(this string text)
{
return Regex.Replace(Regex.Replace(text, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2"), @"(\p{Ll})(\P{Ll})", "$1 $2");
var result = "";
var currentPos = 0;
var lastPos = text.Length - 1;
for (currentPos = 0; currentPos <= lastPos; currentPos++)
{
var curChar = text[currentPos];
var prevChar = curChar;
if (currentPos > 0)
{
prevChar = text[currentPos - 1];
}
if (char.IsUpper(curChar) && char.IsLower(prevChar))
{
result += " ";
}
result += curChar;
}
return result;
}
}
}
@@ -204,6 +204,28 @@ private static void RegisterBuiltInAgorithms()
algorithm.DefaultMiner = MinerNames.SGMinerPascal;
algorithm.MinerArguments[MinerNames.SGMinerPascal] = AlgorithmParameter.AlgorithmPascal;
algorithm.BuiltIn = true;
// required editing lbry.cl, ripemd160.cl and wolf-sha512.cl
algorithm = factory.RegisterAlgorithm(AlgorithmNames.LBRY, AlgorithmFullNames.LBRY);
algorithm.PoolMultiplier = 1;
algorithm.DifficultyMultiplier = Math.Pow(2, 9);
algorithm.DefaultMiner = MinerNames.SGMinerNH;
algorithm.MinerArguments[MinerNames.SGMinerNH] = AlgorithmParameter.AlgorithmLbry;
algorithm.BuiltIn = true;
algorithm = factory.RegisterAlgorithm(AlgorithmNames.Lyra2REv2, AlgorithmFullNames.Lyra2REv2);
algorithm.PoolMultiplier = 1;
algorithm.DifficultyMultiplier = Math.Pow(2, 32);
algorithm.DefaultMiner = MinerNames.SGMinerNH;
algorithm.MinerArguments[MinerNames.SGMinerNH] = AlgorithmParameter.AlgorithmLyra2REv2;
algorithm.BuiltIn = true;
algorithm = factory.RegisterAlgorithm(AlgorithmNames.Nist5, AlgorithmFullNames.Nist5);
algorithm.PoolMultiplier = 1;
algorithm.DifficultyMultiplier = Math.Pow(2, 32);
algorithm.DefaultMiner = MinerNames.SGMinerNH;
algorithm.MinerArguments[MinerNames.SGMinerNH] = AlgorithmParameter.AlgorithmNist5;
algorithm.BuiltIn = true;
}
private static void RegisterMiners()
@@ -220,6 +242,7 @@ private static void RegisterMiners()
factory.RegisterMiner(MinerNames.SGMiner5, MinerNames.SGMiner, true);
factory.RegisterMiner(MinerNames.SGMinerGM, MinerNames.SGMiner, true);
factory.RegisterMiner(MinerNames.SGMinerPascal, MinerNames.SGMiner, true);
factory.RegisterMiner(MinerNames.SGMinerNH, MinerNames.SGMiner, true);
string minersDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Miners");
factory.RegisterMiners(minersDirectory);
@@ -164,5 +164,31 @@ public void PortFromHost_WithoutPort_ReturnsNull()
// assert
Assert.IsFalse(port.HasValue);
}
[TestMethod]
public void DomainFromHost_WithSubdomain_Succeeds()
{
// arrange
var hostAndPort = "stratum+tcp://stratum.slushpool.com";
// act
var host = hostAndPort.DomainFromHost();
// assert
Assert.AreEqual("slushpool", host);
}
[TestMethod]
public void DomainFromHost_WithoutSubdomain_Succeeds()
{
// arrange
var hostAndPort = "stratum+tcp://omegapool.cc";
// act
var host = hostAndPort.DomainFromHost();
// assert
Assert.AreEqual("omegapool", host);
}
}
}
@@ -20,6 +20,8 @@ public static class AlgorithmNames
public const string CryptoNight = "CryptoNight";
public const string Equihash = "Equihash";
public const string Pascal = "Pascal";
public const string LBRY = "LBRY";
public const string Lyra2REv2 = "Lyra2REv2";
}
public static class AlgorithmFullNames
@@ -42,6 +44,8 @@ public static class AlgorithmFullNames
public const string CryptoNight = "CryptoNight";
public const string Equihash = "Equihash";
public const string Pascal = "Pascal";
public const string LBRY = "LBRY";
public const string Lyra2REv2 = "Lyra2REv2";
}
//how difficult is each algo on the same hardware relative to SHA256

0 comments on commit 170f5e4

Please sign in to comment.