Skip to content

Commit

Permalink
Merge pull request clintar#8 from zone117x/tcp-protocol
Browse files Browse the repository at this point in the history
Added TCP protocol
  • Loading branch information
zone117x committed May 24, 2014
2 parents 1fc2920 + 845a9a9 commit ffa56a0
Show file tree
Hide file tree
Showing 7 changed files with 309 additions and 170 deletions.
130 changes: 69 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Comes with lightweight example front-end script which uses the pool's AJAX API.

#### Table of Contents
* [Features](#features)
* [Under Development](#under-development)
* [Community Support](#community--support)
* [Pools Using This Software](#pools-using-this-software)
* [Usage](#usage)
Expand All @@ -28,6 +27,9 @@ Comes with lightweight example front-end script which uses the pool's AJAX API.

#### Features

* TCP (stratum-like) protocol for server-push based jobs
* Compared to old HTTP protocol, this has a higher hash rate, lower network/CPU server load, lower orphan
block percent, and less error prone
* IP banning to prevent low-diff share attacks
* Socket flooding detection
* Payment processing (with splintered transactions to deal with max transaction size)
Expand All @@ -48,10 +50,6 @@ Comes with lightweight example front-end script which uses the pool's AJAX API.
* Worker login validation (make sure miners are using proper wallet addresses for mining)


#### Under Development

* Stratum protocol (push-based TCP sockets) to help reduce server load

### Community / Support

* [CryptoNote Forum](https://forum.cryptonote.org/)
Expand Down Expand Up @@ -111,39 +109,78 @@ Explanation for each field:
/* Used for front-end display */
"symbol": "MRO",

"coinUnits": 100000000,
"transferFee": 1000000,
/* Specifies the level of log output verbosity. Anything more severe than the level specified
will also be logged. */
"logLevel": "debug", //or "warn", "error"

/* By default the pool logs to console and gives pretty colors. If you direct that output to a
log file then disable this feature to avoid nasty characters in your log file. */
"logColors": true,

/* Minimum units in a single coin, for Bytecoin its 100000000. */
"coinUnits": 1000000000000,

/* Host that simpleminer is pointed to. */
"poolHost": "example.com",

/* IRC Server and room used for embedded KiwiIRC chat on fron-end. */
/* IRC Server and room used for embedded KiwiIRC chat on front-end. */
"irc": "irc.freenode.net/#monero",

/* Contact email address. */
"email": "support@cryppit.com",

/* Address where block rewards go, and miner payments come from. */
"poolAddress": "4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn"
/* Market display widget params from https://www.cryptonator.com/widget */
"cryptonatorWidget": "num=2&base_0=Monero%20(MRO)&target_0=Bitcoin%20(BTC)&base_1=Monero%20(MRO)&target_1=US%20Dollar%20(USD)",

/* Download link to cryptonote-easy-miner for Windows users. */
"easyminerDownload": "https://github.com/zone117x/cryptonote-easy-miner/raw/master/CryptoNoteMiner/bin/Release/cryptnote-easy-miner-latest.zip",

/* Download link to simplewallet for your configured coin. */
"simplewalletDownload": "http://bit.ly/monero-starter-pack",

/* Used for front-end block links. For other coins it can be changed, for example with
Bytecoin you can use "https://minergate.com/blockchain/bcn/block/". */
"blockchainExplorer": "http://monerochain.info/block/",

/* Modular Pool Server */
"poolServer": {
"enabled": true,

/* Set to "auto" by default which will spawn one process/fork/worker for each CPU
core in your system. Each of these workers will run a separate instance of your pool(s),
and the kernel will load balance miners using these forks. Optionally, the 'forks' field
can be a number for how many forks will be spawned. */
"clusterForks": "auto",

/* Address where block rewards go, and miner payments come from. */
"poolAddress": "4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn"

/* Poll RPC daemons for new blocks every this many milliseconds. */
"blockRefreshInterval": 1000,

/* How many seconds until we consider a miner disconnected. */
"minerTimeout": 900,

"ports": [
{
"port": 3333, //Port for mining apps to connect to
"difficulty": 50, //Initial difficulty miners are set to
"desc": "Low end CPUs" //Description of port
},
{
"port": 5555,
"difficulty": 200,
"desc": "Mid range CPUs"
"port": 5555, //Port for mining apps to connect to
"protocol": "tcp",
"difficulty": 200, //Initial difficulty miners are set to
"desc": "Mid range CPUs" //Description of port
},
{
"port": 7777,
"protocol": "tcp",
"difficulty": 2000,
"desc": "High end CPUs"
},
/* Old, inefficient protocol which has worse hashrate, higher network/CPU server load,
higher orphan block percent, more error prone, etc. */
{
"port": 1111,
"protocol": "http",
"difficulty": 500,
"desc": "Old protocol"
}
],

Expand All @@ -166,56 +203,27 @@ Explanation for each field:
"stepDown": 3, //Increase trust probability percent this much with each valid share
"threshold": 10, //Amount of valid shares required before trusting begins
"penalty": 30 //Upon breaking trust require this many valid share before re-trusting
}
},

/* Market display widget params from https://www.cryptonator.com/widget */
"cryptonatorWidget": "num=2&base_0=Monero%20(MRO)&target_0=Bitcoin%20(BTC)&base_1=Monero%20(MRO)&target_1=US%20Dollar%20(USD)",

/* Download link to cryptonote-easy-miner for Windows users. */
"easyminerDownload": "https://github.com/zone117x/cryptonote-easy-miner/raw/master/CryptoNoteMiner/bin/Release/cryptnote-easy-miner-latest.zip",

/* Used for front-end block links. For other coins it can be changed, for example with
Bytecoin you can use "https://minergate.com/blockchain/bcn/block/". */
"blockchainExplorer": "http://monerochain.info/block/",

/* Set to "auto" by default which will spawn one process/fork/worker for each CPU
core in your system. Each of these workers will run a separate instance of your pool(s),
and the kernel will load balance miners using these forks. Optionally, the 'forks' field
can be a number for how many forks will be spawned. */
"clusterForks": "auto",

/* Specifies the level of log output verbosity. Anything more severe than the level specified
will also be logged. */
"logLevel": "debug", //or "warn", "error"

/* By default the pool logs to console and gives pretty colors. If you direct that output to a
log file then disable this feature to avoid nasty characters in your log file. */
"logColors": true,

/* Poll RPC daemons for new blocks every this many milliseconds. */
"blockRefreshInterval": 1000,

/* How many seconds until we consider a miner disconnected. */
"minerTimeout": 900,
},

/* Only works with the new simpleminer with longpolling enabled. */
"longPolling": {
"enabled": true,
"timeout": 8500
},
/* Only used with old http protocol and only works with the simpleminer. */
"longPolling": {
"enabled": true,
"timeout": 8500
},

/* If under low-diff share attack we can ban their IP to reduce system/network load. */
"banning": {
"enabled": true,
"time": 600, //How many seconds to ban worker for
"invalidPercent": 25, //What percent of invalid shares triggers ban
"checkThreshold": 30 //Perform check when this many shares have been submitted
/* If under low-diff share attack we can ban their IP to reduce system/network load. */
"banning": {
"enabled": true,
"time": 600, //How many seconds to ban worker for
"invalidPercent": 25, //What percent of invalid shares triggers ban
"checkThreshold": 30 //Perform check when this many shares have been submitted
}
},

/* Module that sends payments to miners according to their submitted shares. */
"payments": {
"enabled": true,
"transferFee": 1000000,
"interval": 30, //how often to run in seconds
"poolFee": 2, //2% pool fee
"depth": 60, //block depth required to send payments (CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW)
Expand Down
69 changes: 35 additions & 34 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,49 @@
"coin": "monero",
"symbol": "MRO",

"logLevel": "debug",
"logColors": true,

"coinUnits": 1000000000000,
"transferFee": 1000000,

"poolHost": "cryppit.com",

"irc": "irc.freenode.net/#monero",

"email": "support@cryppit.com",

"poolAddress": "4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn",
"cryptonatorWidget": "num=2&base_0=Monero%20(MRO)&target_0=Bitcoin%20(BTC)&base_1=Monero%20(MRO)&target_1=US%20Dollar%20(USD)",

"easyminerDownload": "https://github.com/zone117x/cryptonote-easy-miner/releases/",

"simplewalletDownload": "http://bit.ly/monero-starter-pack",

"blockchainExplorer": "http://monerochain.info/block/",

"poolServer": {
"enabled": true,
"clusterForks": "auto",
"poolAddress": "4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn",
"blockRefreshInterval": 1000,
"minerTimeout": 900,
"ports": [
{
"port": 3333,
"difficulty": 50,
"desc": "Low end CPUs"
},
{
"port": 5555,
"protocol": "tcp",
"difficulty": 200,
"desc": "Mid range CPUs"
},
{
"port": 7777,
"protocol": "tcp",
"difficulty": 2000,
"desc": "High end CPUs"
},
{
"port": 1111,
"protocol": "http",
"difficulty": 500,
"desc": "Old protocol"
}
],
"varDiff": {
Expand All @@ -46,38 +62,23 @@
"stepDown": 3,
"threshold": 10,
"penalty": 30
}
},

"cryptonatorWidget": "num=2&base_0=Monero%20(MRO)&target_0=Bitcoin%20(BTC)&base_1=Monero%20(MRO)&target_1=US%20Dollar%20(USD)",

"easyminerDownload": "https://github.com/zone117x/cryptonote-easy-miner/releases/",

"blockchainExplorer": "http://monerochain.info/block/",

"clusterForks": "auto",

"logLevel": "debug",
"logColors": true,

"blockRefreshInterval": 1000,

"minerTimeout": 900,

"longPolling": {
"enabled": false,
"timeout": 8500
},
},
"longPolling": {
"enabled": false,
"timeout": 8500
},

"banning": {
"enabled": true,
"time": 600,
"invalidPercent": 25,
"checkThreshold": 30
"banning": {
"enabled": true,
"time": 600,
"invalidPercent": 25,
"checkThreshold": 30
}
},

"payments": {
"enabled": true,
"transferFee": 1000000,
"interval": 30,
"poolFee": 2,
"depth": 60,
Expand Down
29 changes: 18 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@
margin: 5px;

}
.blocksStatHolder > span > span{

}


#blocks_rows > tr > td:nth-child(4){
font-family: monospace;
Expand Down Expand Up @@ -141,7 +137,11 @@
margin-right: 0;
}

#simpleminer_code{
#getting_started_list > li{
margin-bottom: 20px;
}

#cpuminer_code{
display: inline-block;
white-space: normal;
}
Expand Down Expand Up @@ -298,6 +298,7 @@
var portData = stats.config.ports[i];
var $portChild = $(miningPortTemplate);
$portChild.find('.miningPort').text(portData.port);
$portChild.find('.miningPortProtocol').text(portData.protocol).addClass(portData.protocol === 'tcp' ? 'label label-success' : 'label label-warning');
$portChild.find('.miningPortDiff').text(portData.difficulty);
$portChild.find('.miningPortDesc').text(portData.desc);
$miningPortChildren.push($portChild);
Expand All @@ -307,7 +308,11 @@


$('#easyminer_link').attr('href', stats.config.easyminerDownload);
$('#simpleminer_code').text('simpleminer --pool-addr=' + stats.config.poolHost + ':' + stats.config.ports[0].port + ' --login=address --pass=x');
$('#simplewallet_download').attr('href', stats.config.simplewalletDownload);
$('#cpuminer_code').text('minerd -a cryptonight -o stratum+tcp://'
+ stats.config.poolHost + ':'
+ (stats.config.ports.filter(function(p){return p.protocol === 'tcp'})[0] || {}).port
+ ' -u address -p x');

var kiwiIrc = 'https://kiwiirc.com/client/' + stats.config.irc;
if ($('#kiwi_irc').attr('src') !== kiwiIrc){
Expand Down Expand Up @@ -558,6 +563,7 @@ <h4>Mining Ports</h4>
<div id="miningPorts" class="row">
<div class="stats">
<div><i class="fa fa-tachometer"></i> Port: <span class="miningPort"></span></div>
<div><i class="fa fa-cog"></i> Protocol: <span class="miningPortProtocol"></span></div>
<div><i class="fa fa-unlock-alt"></i> Starting Difficulty: <span class="miningPortDiff"></span></div>
<div><i class="fa fa-question"></i> Description: <span class="miningPortDesc"></span></div>
</div>
Expand All @@ -576,12 +582,13 @@ <h4>For <i class="fa fa-windows"></i> Windows users</h4>

<h4>Or download the the binaries for your system</h4>
<br>
<ol>
<li><a target="_blank" class="btn btn-default btn-sm" href="http://bit.ly/monero-starter-pack"><i class="fa fa-download"></i> Download</a> simpleminer and simplewallet for your system<br><br></li>
<li>Run simplewallet to generate your public address<br><br></li>
<li>Choose a port and run simpleminer pointed to our pool with your address, for example:
<ol id="getting_started_list">
<li><a id="simplewallet_download" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-download"></i> Download</a> simplewallet for your system</li>
<li>Run simplewallet to generate your public address</li>
<li><a target="_blank" class="btn btn-default btn-sm" href="https://github.com/LucasJones/cpuminer-multi/releases/"><i class="fa fa-download"></i> Download</a> CPUMiner-multi</li>
<li>Choose a port and point your miner to our pool with your address, for example:
<br><br>
<code id="simpleminer_code"></code>
<code id="cpuminer_code"></code>
</li>
</ol>
</div>
Expand Down
14 changes: 10 additions & 4 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ function spawnPoolWorkers(){

if (!config.poolServer || !config.poolServer.enabled || !config.poolServer.ports || config.poolServer.ports.length === 0) return;

if (config.poolServer.ports.filter(function(portData){return portData.protocol === 'tcp' || portData.protocol === 'http'}).length === 0){
logger.error(logSystem, logSubsystem, null, 'Pool server enabled but not tcp or http ports specified');
return;
}


var numForks = (function(){
if (!config.clusterForks)
if (!config.poolServer.clusterForks)
return 1;
if (config.clusterForks === 'auto')
if (config.poolServer.clusterForks === 'auto')
return os.cpus().length;
if (isNaN(config.clusterForks))
if (isNaN(config.poolServer.clusterForks))
return 1;
return config.clusterForks;
return config.poolServer.clusterForks;
})();

var poolWorkers = {};
Expand Down
Loading

0 comments on commit ffa56a0

Please sign in to comment.