Skip to content
Permalink
Browse files

Dynamic Templatized WebSite, Optimized GetBlockTemplate, optimized Me…

…rgeMining Block Construction, Solo mining and merged mining
  • Loading branch information
muscleman committed Nov 16, 2019
1 parent f6a69f5 commit 9ea51551340a70b7f10475dfc0eee164bba7ecbf
Showing with 3,768 additions and 8,321 deletions.
  1. +1 −0 .gitignore
  2. +1 −3 README.md
  3. +102 −2 init.js
  4. +1 −1,891 lib/api.js
  5. +1 −125 lib/apiInterfaces.js
  6. +1 −279 lib/blockUnlocker.js
  7. +1 −380 lib/charts.js
  8. +1 −24 lib/chartsDataCollector.js
  9. +1 −0 lib/childDaemon.js
  10. +9 −7 lib/configReader.js
  11. +1 −0 lib/daemon.js
  12. +1 −72 lib/email.js
  13. +1 −25 lib/exceptionWriter.js
  14. +1 −90 lib/logger.js
  15. +1 −616 lib/market.js
  16. +1 −308 lib/notifications.js
  17. +1 −302 lib/paymentProcessor.js
  18. +1 −1,185 lib/pool.js
  19. +1 −62 lib/telegram.js
  20. +1 −347 lib/telegramBot.js
  21. +1 −146 lib/utils.js
  22. +1 −3 package.json
  23. +50 −20 website_example/admin.html
  24. +9 −0 website_example/browserconfig.xml
  25. +4 −1 website_example/config.js
  26. BIN website_example/favicon.ico
  27. +145 −59 website_example/index.html
  28. +1,961 −92 website_example/js/common.js
  29. +1 −1 website_example/lang/languages.js
  30. +3 −2 website_example/lang/ru.json
  31. +2 −1 website_example/lang/zh-CN.json
  32. +63 −34 website_example/pages/admin/monitoring.html
  33. +13 −13 website_example/pages/admin/ports.html
  34. +142 −108 website_example/pages/admin/statistics.html
  35. +4 −4 website_example/pages/admin/tools.html
  36. +87 −52 website_example/pages/admin/userslist.html
  37. +72 −10 website_example/pages/faq.html
  38. +100 −152 website_example/pages/getting_started.html
  39. +163 −252 website_example/pages/home.html
  40. +117 −305 website_example/pages/market.html
  41. +121 −183 website_example/pages/payments.html
  42. +118 −285 website_example/pages/pool_blocks.html
  43. +64 −233 website_example/pages/settings.html
  44. +55 −53 website_example/pages/top10miners.html
  45. +172 −589 website_example/pages/worker_stats.html
  46. +15 −0 website_example/safari-pinned-tab.svg
  47. +19 −0 website_example/site.webmanifest
  48. +132 −0 website_example/themes/custom.css
  49. +5 −5 website_example/themes/default.css
@@ -6,3 +6,4 @@ build/
logs/
website/
custom_coins/
*.swp
@@ -209,8 +209,7 @@ Explanation for each field:
"cnAlgorithm": "cryptonight",
"cnVariant": 1,
"cnBlobType": 0,
"includeHeight":false, /*true to include block.height in job to miner*/
"includeAlgo":"cn/wow", /*wownero specific change to include algo in job to miner*/
/* Logging */
"logging": {
@@ -410,7 +409,6 @@ Explanation for each field:
"wallet": {
"host": "127.0.0.1",
"port": 18982,
"username": "--rpc-username", //monero based wallet authentication
"password": "--rpc-password"
},
104 init.js
@@ -1,4 +1,4 @@
/**
/**
* Cryptonite Node.JS Pool
* https://github.com/dvandal/cryptonote-nodejs-pool
*
@@ -22,12 +22,21 @@ var redis = require('redis');
var redisDB = (config.redis.db && config.redis.db > 0) ? config.redis.db : 0;
global.redisClient = redis.createClient(config.redis.port, config.redis.host, { db: redisDB, auth_pass: config.redis.auth });

if (typeof config.childPools !== 'undefined')
config.childPools = config.childPools.filter(pool => pool.enabled)

// Load pool modules
if (cluster.isWorker){
switch(process.env.workerType){
case 'pool':
require('./lib/pool.js');
break;
case 'daemon':
require('./lib/daemon.js')
break
case 'childDaemon':
require('./lib/childDaemon.js')
break
case 'blockUnlocker':
require('./lib/blockUnlocker.js');
break;
@@ -79,6 +88,9 @@ var singleModule = (function(){
log('info', logSystem, 'Running in single module mode: %s', [singleModule]);

switch(singleModule){
case 'daemon':
spawnDaemon()
break
case 'pool':
spawnPoolWorkers();
break;
@@ -101,6 +113,9 @@ var singleModule = (function(){
}
else{
spawnPoolWorkers();
spawnDaemon();
if (config.poolServer.mergedMining)
spawnChildDaemons();
spawnBlockUnlocker();
spawnPaymentProcessor();
spawnApi();
@@ -154,7 +169,6 @@ function spawnPoolWorkers(){
log('error', logSystem, 'Pool server enabled but no ports specified');
return;
}

var numForks = (function(){
if (!config.poolServer.clusterForks)
return 1;
@@ -204,6 +218,92 @@ function spawnPoolWorkers(){
}, 10);
}

/**
* Spawn pool workers module
**/
function spawnChildDaemons(){
if (!config.poolServer || !config.poolServer.enabled || !config.poolServer.ports || config.poolServer.ports.length === 0) return;

if (config.poolServer.ports.length === 0){

This comment has been minimized.

Copy link
@trasherdk

trasherdk Nov 17, 2019

Contributor

Looks like dead code to me.
The line 225 contains the same check.

log('error', logSystem, 'Pool server enabled but no ports specified');
return;
}

var numForks = (function(){
if (!config.poolServer.mergedMining)
return 0;
if (typeof config.childPools !== 'undefined') {
return config.childPools.length
}
return 0;
})();
var daemonWorkers = {};

var createDaemonWorker = function(poolId){
var worker = cluster.fork({
workerType: 'childDaemon',
poolId: poolId
});
worker.poolId = poolId;
worker.type = 'childDaemon';
daemonWorkers[poolId] = worker;
worker.on('exit', function(code, signal){
log('error', logSystem, 'Child Daemon fork %s died, spawning replacement worker...', [poolId]);
setTimeout(function(){
createDaemonWorker(poolId);
}, 2000);
}).on('message', function(msg){
switch(msg.type){
case 'ChildBlockTemplate':
Object.keys(cluster.workers).forEach(function(id) {
if (cluster.workers[id].type === 'pool'){
cluster.workers[id].send({type: 'ChildBlockTemplate', block: msg.block, poolIndex: msg.poolIndex});
}
});
break;
}
});
};

var i = 0;
var spawnInterval = setInterval(function(){
createDaemonWorker(i.toString())
i++
if (i === numForks){
clearInterval(spawnInterval);
log('info', logSystem, 'Child Daemon spawned on %d thread(s)', [numForks]);
}
}, 10);
}


/**
* Spawn daemon module
**/
function spawnDaemon(){
if (!config.poolServer || !config.poolServer.enabled || !config.poolServer.ports || config.poolServer.ports.length === 0) return;

var worker = cluster.fork({
workerType: 'daemon'
});
worker.on('exit', function(code, signal){
log('error', logSystem, 'Daemon died, spawning replacement...');
setTimeout(function(){
spawnDaemon();
}, 10);
}).on('message', function(msg){
switch(msg.type){
case 'BlockTemplate':
Object.keys(cluster.workers).forEach(function(id) {
if (cluster.workers[id].type === 'pool'){
cluster.workers[id].send({type: 'BlockTemplate', block: msg.block});
}
});
break;
}
});
}

/**
* Spawn block unlocker module
**/

0 comments on commit 9ea5155

Please sign in to comment.
You can’t perform that action at this time.