Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Dev (#595)
Browse files Browse the repository at this point in the history
* Fix appveyor builds
* Bump NLog from 4.5.11 to 4.6.1 in /src/Miningcore (#593)
* Bump prometheus-net from 3.0.3 to 3.1.0 in /src/Miningcore (#592)
* Bump NBitcoin from 4.1.1.82 to 4.1.1.96 in /src/Miningcore (#591)
* Bump FluentValidation from 8.1.3 to 8.2.0 in /src/Miningcore (#590)
* Bump FluentValidation.ValidatorAttribute in /src/Miningcore (#589)
* Bump Autofac from 4.9.1 to 4.9.2 in /src/Miningcore (#583)
* Bump McMaster.Extensions.CommandLineUtils in /src/Miningcore (#580)
* Bump AspNetCoreRateLimit from 3.0.2 to 3.0.3 in /src/Miningcore (#579)
* Bump Polly from 7.0.3 to 7.1.0 in /src/Miningcore (#578)
* Bump prometheus-net.AspNetCore from 3.0.3 to 3.1.0 in /src/Miningcore (#588)
* Bump JetBrains.Annotations from 2018.3.0 to 2019.1.1 in /src/Miningcore (#587)
* Bump Dapper from 1.50.7 to 1.60.6 in /src/Miningcore (#586)
* Add .editorconfig
* Formatting pass
* Add .editorconfig to solution
* Bump NBitcoin from 4.1.1.96 to 4.1.1.97 in /src/Miningcore (#594)
  • Loading branch information
Oliver Weichhold authored Apr 4, 2019
1 parent 115a622 commit 1d79333
Show file tree
Hide file tree
Showing 137 changed files with 5,524 additions and 1,287 deletions.
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ build_script:
- sh: sudo apt-get update -y && sudo apt-get -y install cmake build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5
- # Publish
- cd Miningcore
- dotnet publish -c Release --framework netcoreapp2.1
- dotnet publish -c Release --framework netcoreapp2.2
- # Publish Artifacts
- sh: (cd bin/Release/netcoreapp2.1 && mkdir miningcore && cp -r publish/* miningcore && tar cf miningcore-linux-ubuntu-x64.tar.gz miningcore && appveyor PushArtifact miningcore-linux-ubuntu-x64.tar.gz)
- cmd: cd bin\Release\netcoreapp2.1 && mkdir miningcore && xcopy publish\* miningcore /S && 7z a miningcore-win-x64.zip miningcore && appveyor PushArtifact miningcore-win-x64.zip && cd ..\..\..
- sh: (cd bin/Release/netcoreapp2.2 && mkdir miningcore && cp -r publish/* miningcore && tar cf miningcore-linux-ubuntu-x64.tar.gz miningcore && appveyor PushArtifact miningcore-linux-ubuntu-x64.tar.gz)
- cmd: cd bin\Release\netcoreapp2.2 && mkdir miningcore && xcopy publish\* miningcore /S && 7z a miningcore-win-x64.zip miningcore && appveyor PushArtifact miningcore-win-x64.zip && cd ..\..\..
- # Build Tests
- cd ../Miningcore.Tests
- dotnet build -c Release --framework netcoreapp2.1
- dotnet build -c Release --framework netcoreapp2.2

#---------------------------------#
# tests configuration #
Expand Down
Binary file modified libs/runtimes/win-x64/libcryptonight.dll
Binary file not shown.
26 changes: 26 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.cs]
csharp_space_after_cast = true
csharp_space_after_keywords_in_control_flow_statements = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_around_binary_operators = true

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
24 changes: 12 additions & 12 deletions src/Miningcore.Tests/Blockchain/Bitcoin/BitcoinJobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public BitcoinJobTests()
[Fact]
public void BitcoinJob_Should_Accept_Valid_Share()
{
var worker = new StratumClient();
var worker = new StratumClient();

worker.SetContext(new BitcoinWorkerContext
{
Difficulty = 0.5,
ExtraNonce1 = "01000058",
});
worker.SetContext(new BitcoinWorkerContext
{
Difficulty = 0.5,
ExtraNonce1 = "01000058",
});

var bt = JsonConvert.DeserializeObject<Miningcore.Blockchain.Bitcoin.DaemonResponses.BlockTemplate>(
"{\"Version\":536870912,\"PreviousBlockhash\":\"000000000909578519b5be7b37fdc53b2923817921c43108a907b72264da76bb\",\"CoinbaseValue\":5000000000,\"Target\":\"7fffff0000000000000000000000000000000000000000000000000000000000\",\"NonceRange\":\"00000000ffffffff\",\"CurTime\":1508869874,\"Bits\":\"207fffff\",\"Height\":14,\"Transactions\":[],\"CoinbaseAux\":{\"Flags\":\"0b2f454231362f414431322f\"},\"default_witness_commitment\":null}");
Expand Down Expand Up @@ -69,13 +69,13 @@ public void BitcoinJob_Should_Accept_Valid_Share()
[Fact]
public void BitcoinJob_Should_Not_Accept_Invalid_Share()
{
var worker = new StratumClient();
var worker = new StratumClient();

worker.SetContext(new BitcoinWorkerContext
{
Difficulty = 0.5,
ExtraNonce1 = "01000058",
});
worker.SetContext(new BitcoinWorkerContext
{
Difficulty = 0.5,
ExtraNonce1 = "01000058",
});

var bt = JsonConvert.DeserializeObject<Miningcore.Blockchain.Bitcoin.DaemonResponses.BlockTemplate>(
"{\"Version\":536870912,\"PreviousBlockhash\":\"000000000909578519b5be7b37fdc53b2923817921c43108a907b72264da76bb\",\"CoinbaseValue\":5000000000,\"Target\":\"7fffff0000000000000000000000000000000000000000000000000000000000\",\"NonceRange\":\"00000000ffffffff\",\"CurTime\":1508869874,\"Bits\":\"207fffff\",\"Height\":14,\"Transactions\":[],\"CoinbaseAux\":{\"Flags\":\"0b2f454231362f414431322f\"},\"default_witness_commitment\":null}");
Expand Down
22 changes: 11 additions & 11 deletions src/Miningcore.Tests/Blockchain/Cryptonote/CryptonoteJobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void MoneroJob_PrepareWorkerJob()
[Fact]
public void MoneroJob_Should_Accept_Valid_Share()
{
var worker = new StratumClient();
var worker = new StratumClient();

worker.SetContext(new CryptonoteWorkerContext
{
Difficulty = 1000,
});
worker.SetContext(new CryptonoteWorkerContext
{
Difficulty = 1000,
});

var bt = JsonConvert.DeserializeObject<Miningcore.Blockchain.Cryptonote.DaemonResponses.GetBlockTemplateResponse>(
"{\"blocktemplate_blob\":\"0106e7eabdcf058234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d00000000019c0201ffe00106e3a1a0cc010275d92c0a057aa5f073079694a153d426f837f49fdb9654da10a5364e79a2086280a0d9e61d028b46dca0d04998500b40b046fd6f8bb33229e6380fd465dbb1327aa6f813d8bd80c0fc82aa0202372f076459e769116d604d30aabff7160782acc0d20e0c5cdc8963ed4e16372f8090cad2c60e02f009504ce65538bbb684b466b21be3a90e3740f185d7089d37b75f0cf62b6e7680e08d84ddcb0102cf01b85c0b592bb6e508e20b5d317052b75de121908390363201abff3476ef0180c0caf384a302024b81076c8ad0cfe84cc32fe0813d63cdd0f7d8d0e56d82aa3f58cbbe49d4c61e2b017aaf3074be7ecb30a769595758e4da7c7c87ead864baf89b679b73153dfa352c0208000000000000000000\",\"Difficulty\":2,\"Height\":224,\"prev_hash\":\"8234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d\",\"reserved_offset\":322,\"Status\":\"OK\"}");
Expand All @@ -71,14 +71,14 @@ public void MoneroJob_Should_Accept_Valid_Share()
[Fact]
public void MoneroJob_Should_Not_Accept_Invalid_Share()
{
var worker = new StratumClient();
var worker = new StratumClient();

worker.SetContext(new CryptonoteWorkerContext
{
Difficulty = 1000,
});
worker.SetContext(new CryptonoteWorkerContext
{
Difficulty = 1000,
});

var bt = JsonConvert.DeserializeObject<Miningcore.Blockchain.Cryptonote.DaemonResponses.GetBlockTemplateResponse>(
var bt = JsonConvert.DeserializeObject<Miningcore.Blockchain.Cryptonote.DaemonResponses.GetBlockTemplateResponse>(
"{\"blocktemplate_blob\":\"0106e7eabdcf058234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d00000000019c0201ffe00106e3a1a0cc010275d92c0a057aa5f073079694a153d426f837f49fdb9654da10a5364e79a2086280a0d9e61d028b46dca0d04998500b40b046fd6f8bb33229e6380fd465dbb1327aa6f813d8bd80c0fc82aa0202372f076459e769116d604d30aabff7160782acc0d20e0c5cdc8963ed4e16372f8090cad2c60e02f009504ce65538bbb684b466b21be3a90e3740f185d7089d37b75f0cf62b6e7680e08d84ddcb0102cf01b85c0b592bb6e508e20b5d317052b75de121908390363201abff3476ef0180c0caf384a302024b81076c8ad0cfe84cc32fe0813d63cdd0f7d8d0e56d82aa3f58cbbe49d4c61e2b017aaf3074be7ecb30a769595758e4da7c7c87ead864baf89b679b73153dfa352c0208000000000000000000\",\"Difficulty\":2,\"Height\":224,\"prev_hash\":\"8234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d\",\"reserved_offset\":322,\"Status\":\"OK\"}");

var job = new CryptonoteJob(bt, "d150da".HexToByteArray(), "1", poolConfig, clusterConfig, "");
Expand Down
12 changes: 6 additions & 6 deletions src/Miningcore.Tests/Blockchain/Ethereum/EthereumJobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

namespace Miningcore.Tests.Blockchain.Ethereum
{
/// <summary>
/// These tests take ages to complete (> 10 min. on modern hardware)
/// due to the time it takes to generate the DAG for EthashFull
/// </summary>
public class EthereumJobTests : TestBase
/// <summary>
/// These tests take ages to complete (> 10 min. on modern hardware)
/// due to the time it takes to generate the DAG for EthashFull
/// </summary>
public class EthereumJobTests : TestBase
{
static readonly EthashFull ethash = new EthashFull(3, Path.GetTempPath());

/*
/*
[Fact]
public async Task EthereumJob_Should_Accept_Valid_Share()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Miningcore.Tests/Crypto/CrytonoteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public void Crytonight()
LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0);
var result = buf.ToHexString();
Assert.Equal("a845ffbdf83ae9a8ffa504a1011efbd5ed2294bb9da591d3b583740568402c00", result);
Array.Clear(buf,0, buf.Length);

Array.Clear(buf, 0, buf.Length);

LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0);
result = buf.ToHexString();
Expand Down
2 changes: 1 addition & 1 deletion src/Miningcore.Tests/Crypto/HashingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void Lyra2Rev3_Hash()
{
var hasher = new Lyra2Rev3();
var hash = new byte[32];
hasher.Digest(Enumerable.Repeat((byte)5, 80).ToArray(), hash);
hasher.Digest(Enumerable.Repeat((byte) 5, 80).ToArray(), hash);
var result = hash.ToHexString();

Assert.Equal("c56ec425ada2c8ddcb8d5a79a3a0c9d79f66318193049fb81f875c537a4f963d", result);
Expand Down
6 changes: 3 additions & 3 deletions src/Miningcore.Tests/Crypto/MerkleTreeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void MerkleTree_99HashesTest_Branches()
{

List<byte[]> hashesList = new List<byte[]>();
for (int i = 0; i < 100; i++)
for(int i = 0; i < 100; i++)
{
byte[] value = Encoding.ASCII.GetBytes(i.ToString());
byte[] hash = MerkelHash(value);
Expand All @@ -94,7 +94,7 @@ public void MerkleTree_99HashesTest_Branches()
.ToArray();


foreach (var hex in output)
foreach(var hex in output)
this.output.WriteLine(hex);

string[] expectedOutput = {
Expand All @@ -114,7 +114,7 @@ public void MerkleTree_99HashesTest_Branches()

private static byte[] MerkelHash(byte[] input)
{
using (var hash = SHA256.Create())
using(var hash = SHA256.Create())
{
var first = hash.ComputeHash(input, 0, input.Length);
return hash.ComputeHash(first);
Expand Down
4 changes: 2 additions & 2 deletions src/Miningcore.Tests/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public static class ModuleInitializer
/// </summary>
public static void Initialize()
{
lock (initLock)
lock(initLock)
{
if (isInitialized)
if(isInitialized)
return;

var builder = new ContainerBuilder();
Expand Down
106 changes: 53 additions & 53 deletions src/Miningcore.Tests/VarDiff/VarDiffManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,67 @@ namespace Miningcore.Tests.VarDiff
{
public class VarDiffManagerTests : TestBase
{
/*
private static readonly VarDiffConfig config = new VarDiffConfig
{
RetargetTime = 90,
MinDiff = 1000,
MaxDiff = 10000,
TargetTime = 15,
VariancePercent = 30,
MaxDelta = 1000,
};
/*
private static readonly VarDiffConfig config = new VarDiffConfig
{
RetargetTime = 90,
MinDiff = 1000,
MaxDiff = 10000,
TargetTime = 15,
VariancePercent = 30,
MaxDelta = 1000,
};
private static readonly ILogger logger = LogManager.CreateNullLogger();
private readonly MockMasterClock clock = new MockMasterClock();
private static readonly ILogger logger = LogManager.CreateNullLogger();
private readonly MockMasterClock clock = new MockMasterClock();
[Fact]
public void VarDiff_Should_Honor_MaxDelta_When_Adjusting_Up()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase {Difficulty = 7500, VarDiff = new VarDiffContext() };
[Fact]
public void VarDiff_Should_Honor_MaxDelta_When_Adjusting_Up()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase {Difficulty = 7500, VarDiff = new VarDiffContext() };
var shares = new List<long> { 2, 3, 4 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(8500));
}
var shares = new List<long> { 2, 3, 4 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(8500));
}
[Fact]
public void VarDiff_Should_Honor_MaxDelta_When_Adjusting_Down()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase { Difficulty = 7500, VarDiff = new VarDiffContext() };
[Fact]
public void VarDiff_Should_Honor_MaxDelta_When_Adjusting_Down()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase { Difficulty = 7500, VarDiff = new VarDiffContext() };
var shares = new List<long> { 2000000000, 3000000000, 4000000000 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(6500));
}
var shares = new List<long> { 2000000000, 3000000000, 4000000000 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(6500));
}
[Fact]
public void VarDiff_Should_Honor_MaxDiff_When_Adjusting_Up()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase { Difficulty = 9500, VarDiff = new VarDiffContext() };
[Fact]
public void VarDiff_Should_Honor_MaxDiff_When_Adjusting_Up()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase { Difficulty = 9500, VarDiff = new VarDiffContext() };
var shares = new List<long> { 2, 3, 4 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(10000));
}
var shares = new List<long> { 2, 3, 4 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(10000));
}
[Fact]
public void VarDiff_Should_Honor_MinDiff_When_Adjusting_Down()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase { Difficulty = 1500, VarDiff = new VarDiffContext() };
[Fact]
public void VarDiff_Should_Honor_MinDiff_When_Adjusting_Down()
{
var vdm = new VarDiffManager(config, clock);
var ctx = new WorkerContextBase { Difficulty = 1500, VarDiff = new VarDiffContext() };
var shares = new List<long> { 2000000000, 3000000000, 4000000000 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(1000));
}
*/
var shares = new List<long> { 2000000000, 3000000000, 4000000000 };
var newDiff = vdm.Update(ctx, shares, string.Empty, logger);
Assert.NotNull(newDiff);
Assert.True(newDiff.Value.EqualsDigitPrecision3(1000));
}
*/
}
}
9 changes: 7 additions & 2 deletions src/Miningcore.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
# Visual Studio Version 16
VisualStudioVersion = 16.0.28729.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Miningcore", "Miningcore\Miningcore.csproj", "{A427248A-B5E1-4808-9883-BC2AD68EE997}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Miningcore.Tests", "Miningcore.Tests\Miningcore.Tests.csproj", "{DCDE9CE6-84B8-42FE-AA55-2A3909A5E757}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{71672AAD-51F8-49EC-9EFD-E504D65A765A}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion src/Miningcore/Api/Controllers/AdminApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task<object> AddMinerBalanceAsync(AddBalanceRequest request)
{
request.Usage = request.Usage?.Trim();

if (string.IsNullOrEmpty(request.Usage))
if(string.IsNullOrEmpty(request.Usage))
request.Usage = $"Admin balance change from {Request.HttpContext.Connection.RemoteIpAddress}";

var oldBalance = await cf.Run(con => balanceRepo.GetBalanceAsync(con, request.PoolId, request.Address));
Expand Down
Loading

0 comments on commit 1d79333

Please sign in to comment.