Initial Commit
commit
39730af42a
|
@ -0,0 +1,40 @@
|
||||||
|
# Autosave files
|
||||||
|
*~
|
||||||
|
|
||||||
|
# build
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]in/
|
||||||
|
packages/
|
||||||
|
TestResults/
|
||||||
|
|
||||||
|
# globs
|
||||||
|
Makefile.in
|
||||||
|
*.DS_Store
|
||||||
|
*.sln.cache
|
||||||
|
*.suo
|
||||||
|
*.cache
|
||||||
|
*.pidb
|
||||||
|
*.userprefs
|
||||||
|
*.usertasks
|
||||||
|
config.log
|
||||||
|
config.make
|
||||||
|
config.status
|
||||||
|
aclocal.m4
|
||||||
|
install-sh
|
||||||
|
autom4te.cache/
|
||||||
|
*.user
|
||||||
|
*.tar.gz
|
||||||
|
tarballs/
|
||||||
|
test-results/
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Mac bundle stuff
|
||||||
|
*.dmg
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# resharper
|
||||||
|
*_Resharper.*
|
||||||
|
*.Resharper
|
||||||
|
|
||||||
|
# dotCover
|
||||||
|
*.dotCover
|
|
@ -0,0 +1,5 @@
|
||||||
|
# SharpMining
|
||||||
|
Mono/.NET Implementation of Monero Mining Pool
|
||||||
|
|
||||||
|
more information to come...
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
using System;
|
||||||
|
using cryptonote.rpc;
|
||||||
|
using cryptonote;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
|
||||||
|
namespace SharpMining
|
||||||
|
{
|
||||||
|
public class SharpMining
|
||||||
|
{
|
||||||
|
public static void Main(String[] args)
|
||||||
|
{
|
||||||
|
if (args.Length > 1){
|
||||||
|
Console.WriteLine("usage: SharpMining.exe <config.json>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SharpMining sm = new SharpMining(args);
|
||||||
|
sm.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String configFileName;
|
||||||
|
private JToken config;
|
||||||
|
|
||||||
|
List<Daemon> daemons;
|
||||||
|
|
||||||
|
public SharpMining(String[] args){
|
||||||
|
if (args.Length == 0){
|
||||||
|
configFileName = "sharpmining.json";
|
||||||
|
} else if (args.Length == 1){
|
||||||
|
configFileName = args[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
this.config = JToken.Parse(File.ReadAllText(configFileName));
|
||||||
|
|
||||||
|
this.daemons = new List<Daemon>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Run(){
|
||||||
|
CreateDaemonRPC();
|
||||||
|
|
||||||
|
WorkManager = new WorkManager(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateDaemonRPC(){
|
||||||
|
|
||||||
|
foreach (JToken dc in config["daemons"]){
|
||||||
|
Daemon daemon = new Daemon(dc["host"].ToString(), dc["port"].ToObject<int>());
|
||||||
|
daemons.Add(daemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Daemon[] Daemons { get { return this.daemons.ToArray(); } }
|
||||||
|
public WorkManager WorkManager { get; private set; }
|
||||||
|
|
||||||
|
public Daemon getCheckedDaemon(){
|
||||||
|
foreach (Daemon daemon in this.daemons){
|
||||||
|
if (daemon.check()){
|
||||||
|
return daemon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPoolWalletAddress(){
|
||||||
|
return config["pool"]["wallet"].ToObject<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProjectGuid>{5AE4E72A-253B-4FBD-AD5E-C038D57571D0}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>SharpMining</RootNamespace>
|
||||||
|
<AssemblyName>SharpMining</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="SharpMining.cs" />
|
||||||
|
<Compile Include="WorkManager.cs" />
|
||||||
|
<Compile Include="StratumListener.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="sharpmining.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="README.md" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\cryptonote\cryptonote.csproj">
|
||||||
|
<Project>{52C68C13-2DC2-438A-9EC1-E8C4953B07DF}</Project>
|
||||||
|
<Name>cryptonote</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\JSONRPC\JSONRPC.csproj">
|
||||||
|
<Project>{DCE6066E-9709-4D12-8994-F7879C3557D6}</Project>
|
||||||
|
<Name>JSONRPC</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<ProjectExtensions>
|
||||||
|
<MonoDevelop>
|
||||||
|
<Properties>
|
||||||
|
<Policies>
|
||||||
|
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
|
||||||
|
</Policies>
|
||||||
|
</Properties>
|
||||||
|
</MonoDevelop>
|
||||||
|
</ProjectExtensions>
|
||||||
|
</Project>
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
namespace SharpMining
|
||||||
|
{
|
||||||
|
public class StratumListener
|
||||||
|
{
|
||||||
|
IPEndPoint endpoint;
|
||||||
|
|
||||||
|
|
||||||
|
public StratumListener(IPEndPoint endpoint)
|
||||||
|
{
|
||||||
|
this.endpoint = endpoint;
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StratumListener(IPAddress bind,int port){
|
||||||
|
this.endpoint = new IPEndPoint(bind, port);
|
||||||
|
this.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using cryptonote;
|
||||||
|
using cryptonote.rpc;
|
||||||
|
namespace SharpMining
|
||||||
|
{
|
||||||
|
public class WorkManager
|
||||||
|
{
|
||||||
|
SharpMining sharpMining;
|
||||||
|
Thread thread;
|
||||||
|
|
||||||
|
BlockTemplate currentTemplate;
|
||||||
|
|
||||||
|
public WorkManager(SharpMining sharpMining)
|
||||||
|
{
|
||||||
|
this.sharpMining = sharpMining;
|
||||||
|
this.thread = new Thread(() => Run());
|
||||||
|
this.thread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Run(){
|
||||||
|
while (true){
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
Console.WriteLine("Checking for new work...");
|
||||||
|
|
||||||
|
Daemon daemon = sharpMining.getCheckedDaemon();
|
||||||
|
if (daemon == null){
|
||||||
|
Console.WriteLine("WorkManager: now Daemon available");
|
||||||
|
} else {
|
||||||
|
BlockTemplate newTemplate = daemon.getBlockTemplate(sharpMining.getPoolWalletAddress(), 128);
|
||||||
|
Console.WriteLine("current target height is {0}",newTemplate.Height);
|
||||||
|
|
||||||
|
if ((currentTemplate == null) || (currentTemplate.Height != newTemplate.Height)){
|
||||||
|
changeCurrentBlock(newTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeCurrentBlock(BlockTemplate blockTemplate){
|
||||||
|
currentTemplate = blockTemplate;
|
||||||
|
Console.WriteLine("new block target height: {0} target difficulty: {1} [0x{1:x}]",blockTemplate.Height,blockTemplate.Difficulty,blockTemplate.Difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
namespace SharpMining
|
||||||
|
{
|
||||||
|
public class daemon
|
||||||
|
{
|
||||||
|
public daemon()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net47" />
|
||||||
|
</packages>
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
daemons: [
|
||||||
|
{ host: "10.0.0.1", port: 18081 },
|
||||||
|
{ host: "10.118.0.1", port: 18081 }
|
||||||
|
],
|
||||||
|
|
||||||
|
wallets: [
|
||||||
|
{ host: "10.0.0.1", port: 18082 },
|
||||||
|
],
|
||||||
|
|
||||||
|
rpc: {
|
||||||
|
bind: "127.0.0.1",
|
||||||
|
port: "8880"
|
||||||
|
},
|
||||||
|
|
||||||
|
pool: {
|
||||||
|
// wallet: null
|
||||||
|
wallet: "45YKUs6Lr8562D1vwUfVGPZR7RZp4vqnL95XMvZJEnjREiwEjs8RscC8Djxg5jRzbDAnbK6A9Z9M9VTeMjn9EG1D4Ly7U4i"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
contact: "info@lupus-nobilis.de"
|
||||||
|
}
|
Loading…
Reference in New Issue