Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Added single module mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x committed Jun 28, 2014
1 parent b6cdb4b commit 100da95
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,19 @@ The file `config.json` is used by default but a file can be specified using the
node init.js -config=config_backup.json
```

This software contains four distinct modules:
* `pool` - Which opens ports for miners to connect and processes shares
* `api` - Used by the website to display network, pool and miners' data
* `unlocker` - Processes block candidates and increases miners' balances when blocks are unlocked
* `payments` - Sends out payments to miners according to their balances stored in redis


By default, running the `init.js` script will start up all four modules. You can optionally have the script start
only start a specific module by using the `-module=name` command argument, for example:

```bash
node init.js -module=api
```

#### 5) Host the front-end

Expand Down
55 changes: 48 additions & 7 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var redis = require('redis');
var configFile = (function(){
for (var i = 0; i < process.argv.length; i++){
if (process.argv[i].indexOf('-config=') === 0)
return process.argv[i].split('=')[1];
return process.argv[i].split('=')[1];
}
return 'config.json';
})();
Expand All @@ -22,7 +22,7 @@ catch(e){
return;
}

config.version = "v0.98.5";
config.version = "v0.98.6";

require('./lib/logger.js');

Expand Down Expand Up @@ -55,13 +55,54 @@ var logSystem = 'master';
require('./lib/exceptionWriter.js')(logSystem);


var singleModule = (function(){

var validModules = ['pool', 'api', 'unlocker', 'payments'];

for (var i = 0; i < process.argv.length; i++){
if (process.argv[i].indexOf('-module=') === 0){
var moduleName = process.argv[i].split('=')[1];
if (validModules.indexOf(moduleName) > -1)
return moduleName;

log('error', logSystem, 'Invalid module "%s", valid modules: %s', [moduleName, validModules.join(', ')]);
process.exit();
}
}
})();


(function init(){

checkRedisVersion(function(){
spawnPoolWorkers();
spawnBlockUnlocker();
spawnPaymentProcessor();
spawnApi();

if (singleModule){
log('info', logSystem, 'Running in single module mode: %s', [singleModule]);

switch(singleModule){
case 'pool':
spawnPoolWorkers();
break;
case 'unlocker':
spawnBlockUnlocker();
break;
case 'payments':
spawnPaymentProcessor();
break;
case 'api':
spawnApi();
break;
}
}
else{
spawnPoolWorkers();
spawnBlockUnlocker();
spawnPaymentProcessor();
spawnApi();
}

spawnCli();

});
})();

Expand All @@ -87,7 +128,7 @@ function checkRedisVersion(callback){
}
}
if (!version){
log('error', logSystem, 'Could not detect redis version - but be super old or broken');
log('error', logSystem, 'Could not detect redis version - must be super old or broken');
return;
}
else if (version < 2.6){
Expand Down
3 changes: 0 additions & 3 deletions lib/blockUnlocker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var fs = require('fs');

var async = require('async');

var apiInterfaces = require('./apiInterfaces.js')(config.daemon, config.wallet);
Expand Down Expand Up @@ -30,7 +28,6 @@ var devDonationAddress = '45Jmf8PnJKziGyrLouJMeBFw2yVyX1QB52sKEQ4S1VSU2NVsaVGPNu

var doDonations = config.blockUnlocker.devDonation > 0 && devDonationAddress[0] === config.poolServer.poolAddress[0];

console.log('do donations ' + doDonations);

function runInterval(){
async.waterfall([
Expand Down
5 changes: 4 additions & 1 deletion website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@

$('#addressError').hide();
$('#yourAddressDisplay').text(address);
$('#yourLastShare').timeago('update', new Date(parseInt(data.stats.lastShare) * 1000).toISOString());
if (data.stats.lastShare)
$('#yourLastShare').timeago('update', new Date(parseInt(data.stats.lastShare) * 1000).toISOString());
else
$('#yourLastShare').text('Never');
$('#yourHashrateHolder').text((data.stats.hashrate || '0 H') + '/sec');
$('#yourHashes').text(data.stats.hashes || '0');
$('#yourPaid').text(getReadableCoins(data.stats.paid) + ' ' + data.stats.symbol);
Expand Down

0 comments on commit 100da95

Please sign in to comment.