Skip to content

Commit

Permalink
Dev (oliverw#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Weichhold authored Sep 30, 2018
1 parent 893c653 commit 1638adf
Show file tree
Hide file tree
Showing 33 changed files with 640 additions and 643 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ build/
*.ilk
*.meta
*.obj
*.o
*.so
*.pch
*.pdb
*.pgc
Expand Down Expand Up @@ -111,10 +113,5 @@ $RECYCLE.BIN/

logs/

src/multihash-native/**/*.o

recovered-shares.json


src/MiningCore/config\.json
/src/MiningCore/config2.json
55 changes: 30 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,27 @@ This software comes with a built-in donation of 0.1% per block-reward to support
* BTG: `GQb77ZuMCyJGZFyxpzqNfm7GB1rQreP4n6`
* XMR: `475YVJbPHPedudkhrcNp1wDcLMTGYusGPF5fqE7XjnragVLPdqbCHBdZg3dF4dN9hXMjjvGbykS6a77dTAQvGrpiQqHp2eH`

### Runtime Requirements
### Runtime Requirements on Windows

- [.Net Core 2.1 SDK](https://www.microsoft.com/net/download/core#/sdk)
- [.Net Core 2.1 Runtime](https://www.microsoft.com/net/download/core)
- [PostgreSQL Database](https://www.postgresql.org/)
- Coin Daemon (per pool)

### Runtime Requirements on Linux

- [.Net Core 2.1 SDK](https://www.microsoft.com/net/download/core)
- [PostgreSQL Database](https://www.postgresql.org/)
- On Linux you also need to install the libzmq package for your platform (Ubuntu/Debian: libzmq5, CentOS epel: zeromq)
- Coin Daemon (per pool)
- To build and run on Linux refer to the section below
- MiningCore needs to be built from source on Linux. Refer to the section further down below for instructions.

### Running pre-built Release Binaries on Windows

- Download miningcore-win-x64.zip from the latest [Release](https://github.com/coinfoundry/miningcore/releases)
- Extract the Archive
- Setup the database as outlined below
- Create a configuration file <code>config.json</code> as described [here](https://github.com/coinfoundry/miningcore/wiki/Configuration)
- Run <code>dotnet MiningCore.dll -c config.json</code>

### PostgreSQL Database setup

Expand Down Expand Up @@ -117,21 +131,9 @@ $ psql -d miningcore -U miningcore -f createdb.sql

### [API](https://github.com/coinfoundry/miningcore/wiki/API)

### Docker
### Building from Source

The official [miningcore docker image](https://hub.docker.com/r/coinfoundry/miningcore-docker/) expects a valid pool configuration file as volume argument:

```console
$ docker run -d -p 3032:3032 -v /path/to/config.json:/config.json:ro coinfoundry/miningcore-docker
```

You also need to expose all stratum ports specified in your configuration file.

### Building from Source (Shell)

Install the [.Net Core 2.1 SDK](https://www.microsoft.com/net/download/core) for your platform

#### Linux (Ubuntu 16.04 example)
#### Building on Ubuntu 16.04

```console
$ wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
Expand All @@ -145,25 +147,28 @@ $ cd miningcore/src/MiningCore
$ ./linux-build.sh
```

#### Windows
#### Building on Windows

Download and install the [.Net Core 2.1 SDK](https://www.microsoft.com/net/download/core)

```dosbatch
> git clone https://github.com/coinfoundry/miningcore
> cd miningcore/src/MiningCore
> windows-build.bat
```

#### Building on Windows - Visual Studio

- Download and install the [.Net Core 2.1 SDK](https://www.microsoft.com/net/download/core)
- Install [Visual Studio 2017](https://www.visualstudio.com/vs/). Visual Studio Community Edition is fine.
- Open `MiningCore.sln` in VS 2017


#### After successful build

Now copy `config.json` to `../../build`, edit it to your liking and run:
Create a configuration file <code>config.json</code> as described [here](https://github.com/coinfoundry/miningcore/wiki/Configuration)

```
cd ../../build
dotnet MiningCore.dll -c config.json
```

### Building from Source (Visual Studio)

- Install [Visual Studio 2017](https://www.visualstudio.com/vs/) (Community Edition is sufficient) for your platform
- Install [.Net Core 2.0 SDK](https://www.microsoft.com/net/download/core) for your platform
- Open `MiningCore.sln` in VS 2017
19 changes: 15 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@
# Build worker image (VM template)
image:
- Visual Studio 2017
- Ubuntu

#---------------------------------#
# build configuration #
#---------------------------------#

# scripts to run before build
before_build: dotnet restore src
before_build:
- cd src
- dotnet restore

build_script:
- cd src\MiningCore
- # Install Linux build-dependencies
- 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
- # 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 ..\..\..
- # Build Tests
- cd ../MiningCore.Tests
- dotnet build -c Release --framework netcoreapp2.1

#---------------------------------#
Expand All @@ -23,8 +35,7 @@ build_script:

# to run tests again only selected assemblies and/or categories
test_script:
- cd ..\MiningCore.Tests
- dotnet test
- dotnet test -c Release --no-build

#---------------------------------#
# notifications #
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 35 additions & 11 deletions src/MiningCore.Tests/MiningCore.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
</PropertyGroup>

<IsPackable>false</IsPackable>
<PropertyGroup>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<Compile Remove="JsonRpc\**" />
<EmbeddedResource Remove="JsonRpc\**" />
<None Remove="JsonRpc\**" />
<ItemGroup>
<Compile Remove="JsonRpc\**" />
<EmbeddedResource Remove="JsonRpc\**" />
<None Remove="JsonRpc\**" />
</ItemGroup>

<ItemGroup>
Expand All @@ -40,4 +47,21 @@
</None>
</ItemGroup>

<!-- Copy library binaries from MiningCore build output on Windows -->
<Target Name="CopyLibsWin" AfterTargets="AfterBuild" Condition="'$(IsWindows)' == 'true'">
<ItemGroup>
<Libs Include="$(ProjectDir)..\MiningCore\bin\$(Configuration)\netcoreapp2.1\lib*.dll"/>
</ItemGroup>

<Copy SourceFiles="@(Libs)" DestinationFolder="$(OutDir)" />
</Target>

<!-- Copy library binaries from MiningCore build output on Linux -->
<Target Name="CopyLibsLinux" AfterTargets="AfterBuild" Condition="'$(IsLinux)' == 'true'">
<ItemGroup>
<Libs Include="$(ProjectDir)..\MiningCore\bin\$(Configuration)\netcoreapp2.1\lib*.so"/>
</ItemGroup>

<Copy SourceFiles="@(Libs)" DestinationFolder="$(OutDir)" />
</Target>
</Project>
2 changes: 0 additions & 2 deletions src/MiningCore.Tests/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public static void Initialize()
if (isInitialized)
return;

Program.PreloadNativeLibs();

var builder = new ContainerBuilder();

builder.RegisterAssemblyModules(typeof(AutofacModule).GetTypeInfo().Assembly);
Expand Down
6 changes: 4 additions & 2 deletions src/MiningCore/Blockchain/Bitcoin/BitcoinJobManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ protected virtual void SetupJobUpdates()
if (poolConfig.BlockRefreshInterval > 0)
{
// periodically update block-template
triggers.Add(Observable.Timer(TimeSpan.FromMilliseconds(poolConfig.BlockRefreshInterval))
var pollingInterval = poolConfig.BlockRefreshInterval > 0 ? poolConfig.BlockRefreshInterval : 1000;

triggers.Add(Observable.Timer(TimeSpan.FromMilliseconds(pollingInterval))
.TakeUntil(pollTimerRestart)
.Select(_ => (false, "RPC polling", (string) null))
.Repeat());
Expand Down Expand Up @@ -440,7 +442,7 @@ public virtual async Task<bool> ValidateAddressAsync(string address, Cancellatio
{
Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(address), $"{nameof(address)} must not be empty");

var result = await daemon.ExecuteCmdAnyAsync<ValidateAddressResponse>(
var result = await daemon.ExecuteCmdAnyAsync<ValidateAddressResponse>(ct,
BitcoinCommands.ValidateAddress, new[] { address });

return result.Response != null && result.Response.IsValid;
Expand Down
Loading

0 comments on commit 1638adf

Please sign in to comment.