diff --git a/.gitignore b/.gitignore index b2f46e49b..ffa3e751c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/ config.json pool_configs/*.json !pool_configs/litecoin_example.json +!pool_configs/cpuchain_example.json diff --git a/README.md b/README.md index 85d400c94..11f5d1e96 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ responsive user-friendly front-end website featuring mining instructions, in-dep #### Production Usage Notice This is beta software. All of the following are things that can change and break an existing NOMP setup: functionality of any feature, structure of configuration files and structure of redis data. If you use this software in production then *DO NOT* pull new code straight into production usage because it can and often will break your setup and require you to tweak things like config files or redis data. +#### Paid Solution +Usage of this software requires abilities with sysadmin, database admin, coin daemons, and sometimes a bit of programming. Running a production pool can literally be more work than a full-time job. + + +**Coin switching & auto-exchanging for payouts in BTC/LTC** to miners is a feature that very likely will not be included in this project. + #### Table of Contents * [Features](#features) @@ -101,25 +107,6 @@ Join our subreddit [/r/nomp](http://reddit.com/r/nomp)! *Having problems getting the portal running due to some module dependency error?* It's probably because you didn't follow the instructions in this README. Please __read the usage instructions__ including [requirements](#requirements) and [downloading/installing](#1-downloading--installing). If you've followed the instructions completely and are still having problems then open an issue here on github or join our #nomp IRC channel and explain your problem :). -If your pool uses NOMP let us know and we will list your website here. - -##### Some pools using NOMP or node-stratum-module: -* http://chunkypools.com -* http://clevermining.com -* http://rapidhash.net -* http://suchpool.pw -* http://hashfaster.com -* http://miningpoolhub.com -* http://teamdoge.com -* http://miningwith.us -* http://kryptochaos.com -* http://uberpools.org -* http://onebtcplace.com -* http://minr.es -* http://mining.theminingpools.com -* http://www.omargpools.ca/pools.html -* http://pool.trademybit.com/ - Usage ===== @@ -348,7 +335,7 @@ Here is an example of the required fields: source code as the pchMessageStart variable. For example, litecoin mainnet magic: http://git.io/Bi8YFw And for litecoin testnet magic: http://git.io/NXBYJA */ - "peerMagic": "fbc0b6db" //optional + "peerMagic": "fbc0b6db", //optional "peerMagicTestnet": "fcc1b7dc" //optional //"txMessages": false, //options - defaults to false @@ -524,7 +511,7 @@ output from NOMP. #### Upgrading NOMP When updating NOMP to the latest code its important to not only `git pull` the latest from this repo, but to also update -the `node-statum-pool` and `node-multi-hashing` modules, and any config files that may have been changed. +the `node-stratum-pool` and `node-multi-hashing` modules, and any config files that may have been changed. * Inside your NOMP directory (where the init.js script is) do `git pull` to get the latest NOMP code. * Remove the dependenices by deleting the `node_modules` directory with `rm -r node_modules`. * Run `npm update` to force updating/reinstalling of the dependencies. diff --git a/coins/00_example.json b/coins/00_example.json new file mode 100644 index 000000000..9d36bba15 --- /dev/null +++ b/coins/00_example.json @@ -0,0 +1,25 @@ +{ + "name": "Example", + "symbol": "EXM", + "algorithm": "x99", + "peerMagic": "0f0f0f0f", + "peerMagicTestnet": "f0f0f0f0", + + "mainnet": { + "bech32": "ex", + "bip32": { + "public": "0f0f0f0f" + }, + "pubKeyHash": "00", + "scriptHash": "ff" + }, + + "testnet": { + "bech32": "tex", + "bip32": { + "public": "f0f0f0f0" + }, + "pubKeyHash": "0f", + "scriptHash": "f0" + } +} diff --git a/coins/21coin.json b/coins/21coin.json index 8aa9ea57f..5fa143c77 100644 --- a/coins/21coin.json +++ b/coins/21coin.json @@ -1,5 +1,7 @@ { "name": "21coin", "symbol": "21", - "algorithm": "sha256" + "algorithm": "sha256", │····································· + "peerMagic": "21212121", │····································· + "peerMagicTestnet": "01fefe05" } diff --git a/coins/42.json b/coins/42.json new file mode 100644 index 000000000..a3f8b47fa --- /dev/null +++ b/coins/42.json @@ -0,0 +1,5 @@ +{ + "name": "42", + "symbol": "42", + "algorithm": "scrypt" +} diff --git a/coins/alphacoin.json b/coins/alphacoin.json index 2d25d0eb7..c1b4246db 100644 --- a/coins/alphacoin.json +++ b/coins/alphacoin.json @@ -1,5 +1,7 @@ { "name": "Alphacoin", "symbol": "ALF", - "algorithm": "scrypt" -} \ No newline at end of file + "algorithm": "scrypt", + "peerMagic": "fbc0b6db", + "peerMagicTestnet": "fcc1b7dc" +} diff --git a/coins/benjamins.json b/coins/benjamins.json index e73a1b6b6..04ca3c0ba 100644 --- a/coins/benjamins.json +++ b/coins/benjamins.json @@ -1,5 +1,7 @@ { "name": "Benjamins", "symbol": "BEN", - "algorithm": "sha256" + "algorithm": "sha256", + "peerMagic": "de698778", │····································· + "peerMagicTestnet": "0b110907" } diff --git a/coins/bottlecaps.json b/coins/bottlecaps.json index 1dcccb905..8274e17cb 100644 --- a/coins/bottlecaps.json +++ b/coins/bottlecaps.json @@ -1,5 +1,7 @@ { "name": "Bottlecaps", "symbol": "CAP", - "algorithm": "scrypt" -} \ No newline at end of file + "algorithm": "scrypt", + "peerMagic": "e4e8e9e5", + "peerMagicTestnet": "cdf2c0ef" +} diff --git a/coins/bunnycoin.json b/coins/bunnycoin.json new file mode 100644 index 000000000..55d8fe771 --- /dev/null +++ b/coins/bunnycoin.json @@ -0,0 +1,7 @@ +{ + "name": "BunnyCoin", + "symbol": "BUN", + "algorithm": "scrypt", + "peerMagic": "c0c0c0c0", + "peerMagicTestnet": "fcc1b7dc" + } diff --git a/coins/casinocoin.json b/coins/casinocoin.json index d6b396fdd..fa38a544e 100644 --- a/coins/casinocoin.json +++ b/coins/casinocoin.json @@ -1,5 +1,7 @@ { "name": "Casinocoin", "symbol": "CSC", - "algorithm": "scrypt" -} \ No newline at end of file + "algorithm": "scrypt", + "peerMagic": "fac3b6da", + "peerMagicTestnet": "fcc1b7dc" +} diff --git a/coins/chaincoin.json b/coins/chaincoin.json new file mode 100644 index 000000000..af289e36c --- /dev/null +++ b/coins/chaincoin.json @@ -0,0 +1,25 @@ +{ + "name": "Chaincoin", + "symbol": "CHC", + "algorithm": "c11", + "peerMagic": "a3d27a03", + "peerMagicTestnet": "fbc21102", + + "mainnet": { + "bech32": "chc", + "bip32": { + "public": "0488b21e" + }, + "pubKeyHash": "1c", + "scriptHash": "04" + }, + + "testnet": { + "bech32": "tchc", + "bip32": { + "public": "043587cf" + }, + "pubKeyHash": "50", + "scriptHash": "2c" + } +} diff --git a/coins/coino.json b/coins/coino.json new file mode 100644 index 000000000..8d30f75e6 --- /dev/null +++ b/coins/coino.json @@ -0,0 +1,7 @@ +{ + "name": "Coino", + "symbol": "COINO", + "algorithm": "scrypt", + "peerMagic": "f1d1a7d8", + "peerMagicTestnet": "fcc1b7dc" +} diff --git a/coins/cpuchain.json b/coins/cpuchain.json new file mode 100644 index 000000000..31dcf137c --- /dev/null +++ b/coins/cpuchain.json @@ -0,0 +1,16 @@ +{ + "name": "CPUchain", + "symbol": "CPU", + "algorithm": "cpupower", + "peerMagic": "deadbeef", + "peerMagicTestnet": "faceb00c", + + "mainnet": { + "bech32": "cpu", + "bip32": { + "public": "0488B21E" + }, + "pubKeyHash": "1C", + "scriptHash": "1E" + } +} diff --git a/coins/cryptogenicbullion.json b/coins/cryptogenicbullion.json new file mode 100644 index 000000000..dac937c16 --- /dev/null +++ b/coins/cryptogenicbullion.json @@ -0,0 +1,7 @@ +{ + "name": "CryptogenicBullion", + "symbol": "CGB", + "algorithm": "scrypt", + "peerMagic": "e4e8e9e5", + "peerMagicTestnet": "cdf2c0ef" +} diff --git a/coins/cryptographicanomaly.json b/coins/cryptographicanomaly.json new file mode 100644 index 000000000..8c97ff1ed --- /dev/null +++ b/coins/cryptographicanomaly.json @@ -0,0 +1,7 @@ +{ + "name": "CryptographicAnomaly", + "symbol": "CGA", + "algorithm": "scrypt", + "peerMagic": "fbc0b6db", + "peerMagicTestnet": "fcc1b7dc" +} diff --git a/coins/digibyte.json b/coins/digibyte.json index ed65fed61..52ad88e0d 100644 --- a/coins/digibyte.json +++ b/coins/digibyte.json @@ -1,5 +1,7 @@ { "name": "Digibyte", "symbol": "DGB", - "algorithm": "scrypt" + "algorithm": "scrypt", + "peerMagic": "fac3b6da", + "peerMagicTestnet": "fdc8bddd" } \ No newline at end of file diff --git a/coins/emark.json b/coins/emark.json index d14cd3eff..076b33808 100644 --- a/coins/emark.json +++ b/coins/emark.json @@ -1,5 +1,6 @@ { "name": "eMark", "symbol": "DEM", - "algorithm": "sha256" + "algorithm": "sha256", + "reward": "POS" } diff --git a/coins/fluttercoin.json b/coins/fluttercoin.json new file mode 100644 index 000000000..81b5dfb0a --- /dev/null +++ b/coins/fluttercoin.json @@ -0,0 +1,5 @@ +{ + "name": "FlutterCoin", + "symbol": "FLT", + "algorithm": "scrypt" +} diff --git a/coins/globaltoken.json b/coins/globaltoken.json new file mode 100644 index 000000000..580b5cd7e --- /dev/null +++ b/coins/globaltoken.json @@ -0,0 +1,7 @@ +{ + "name": "GlobalToken", + "symbol": "GLT", + "algorithm": "sha256", + "peerMagic": "c708d32d", + "peerMagicTestnet": "3a6f375b" +} diff --git a/coins/infinitecoin.conf b/coins/infinitecoin.conf new file mode 100644 index 000000000..a81791b65 --- /dev/null +++ b/coins/infinitecoin.conf @@ -0,0 +1,7 @@ +{ + "name": "Infinitecoin", + "symbol": "IFC", + "algorithm": "scrypt", + "peerMagic": "fbc0b6db", + "peerMagicTestnet": "fcc1b7dc" +} diff --git a/coins/kumacoin.json b/coins/kumacoin.json new file mode 100644 index 000000000..ab7e895d4 --- /dev/null +++ b/coins/kumacoin.json @@ -0,0 +1,6 @@ +{ + "name": "Kumacoin", + "symbol": "KUMA", + "algorithm": "quark", + "mposDiffMultiplier": 256 +} diff --git a/coins/litecoin.json b/coins/litecoin.json index 588af554f..03e9a55d1 100644 --- a/coins/litecoin.json +++ b/coins/litecoin.json @@ -1,7 +1,25 @@ { - "name": "Litecoin", - "symbol": "LTC", - "algorithm": "scrypt", - "peerMagic": "fbc0b6db", - "peerMagicTestnet": "fcc1b7dc" -} \ No newline at end of file + "name": "Litecoin", + "symbol": "LTC", + "algorithm": "scrypt", + "peerMagic": "fbc0b6db", + "peerMagicTestnet": "fdd2c8f1", + + "mainnet": { + "bech32": "ltc", + "bip32": { + "public": "0488B21E" + }, + "pubKeyHash": "30", + "scriptHash": "05" + }, + + "testnet": { + "bech32": "tltc", + "bip32": { + "public": "043587CF" + }, + "pubKeyHash": "6F", + "scriptHash": "C4" + } +} diff --git a/coins/mazacoin.json b/coins/mazacoin.json index 451738c49..9bc4ed965 100644 --- a/coins/mazacoin.json +++ b/coins/mazacoin.json @@ -1,5 +1,7 @@ { "name": "Mazacoin", "symbol": "MZC", - "algorithm": "sha256" + "algorithm": "sha256", + "peerMagic": "f8b503df", │····································· + "peerMagicTestnet": "05fea901" } diff --git a/coins/monacoin.json b/coins/monacoin.json new file mode 100644 index 000000000..d8897d43c --- /dev/null +++ b/coins/monacoin.json @@ -0,0 +1,5 @@ +{ + "name": "Monacoin", + "symbol": "MONA", + "algorithm": "scrypt" +} \ No newline at end of file diff --git a/coins/sayacoin.json b/coins/sayacoin.json new file mode 100644 index 000000000..933c87904 --- /dev/null +++ b/coins/sayacoin.json @@ -0,0 +1,5 @@ +{ + "name": "Sayacoin", + "symbol": "SYC", + "algorithm": "sha256" +} \ No newline at end of file diff --git a/coins/sha1coin.json b/coins/sha1coin.json new file mode 100644 index 000000000..81e0fd474 --- /dev/null +++ b/coins/sha1coin.json @@ -0,0 +1,5 @@ +{ + "name": "Sha1coin", + "symbol": "SHA", + "algorithm": "sha1coin" +} diff --git a/coins/viacoin.json b/coins/viacoin.json new file mode 100644 index 000000000..30157c9d3 --- /dev/null +++ b/coins/viacoin.json @@ -0,0 +1,7 @@ +{ + "name": "Viacoin", + "symbol": "VIA", + "algorithm": "scrypt", + "peerMagic": "0f68c6cb", + "peerMagicTestnet": "a9c5ef92" +} diff --git a/init.js b/init.js index fc8a81bb1..eadb314b8 100644 --- a/init.js +++ b/init.js @@ -82,6 +82,10 @@ if (cluster.isWorker){ case 'profitSwitch': new ProfitSwitch(logger); break; + case 'switchingPaymentProcessor': + var SwitchingPaymentProcessor = require('./libs/switchingPaymentProcessor.js'); + new SwitchingPaymentProcessor(logger); + break; } return; @@ -143,6 +147,17 @@ var buildPoolConfigs = function(){ var coinProfile = JSON.parse(JSON.minify(fs.readFileSync(coinFilePath, {encoding: 'utf8'}))); poolOptions.coin = coinProfile; poolOptions.coin.name = poolOptions.coin.name.toLowerCase(); + if (coinProfile.mainnet) { + poolOptions.coin.mainnet.bip32.public = Buffer.from(coinProfile.mainnet.bip32.public, 'hex').readUInt32LE(0); + poolOptions.coin.mainnet.pubKeyHash = Buffer.from(coinProfile.mainnet.pubKeyHash, 'hex').readUInt8(0); + poolOptions.coin.mainnet.scriptHash = Buffer.from(coinProfile.mainnet.scriptHash, 'hex').readUInt8(0); + } + if (coinProfile.testnet) { + poolOptions.coin.testnet.bip32.public = Buffer.from(coinProfile.testnet.bip32.public, 'hex').readUInt32LE(0); + poolOptions.coin.testnet.pubKeyHash = Buffer.from(coinProfile.testnet.pubKeyHash, 'hex').readUInt8(0); + poolOptions.coin.testnet.scriptHash = Buffer.from(coinProfile.testnet.scriptHash, 'hex').readUInt8(0); + } + if (poolOptions.coin.name in configs){ @@ -356,7 +371,21 @@ var processCoinSwitchCommand = function(params, options, reply){ }; +var startSwitchingPaymentProcessor = function(){ + if (!fs.existsSync('libs/switchingPaymentProcessor.js')) return; + var worker = cluster.fork({ + workerType: 'switchingPaymentProcessor', + pools: JSON.stringify(poolConfigs), + portalConfig: JSON.stringify(portalConfig) + }); + worker.on('exit', function(code, signal){ + logger.error('Master', 'Switching Payment Processor', 'Died, spawning replacement...'); + setTimeout(function(){ + startSwitchingPaymentProcessor(); + }, 2000); + }); +}; var startPaymentProcessor = function(){ @@ -434,6 +463,8 @@ var startProfitSwitch = function(){ startPaymentProcessor(); + startSwitchingPaymentProcessor(); + startWebsite(); startProfitSwitch(); diff --git a/libs/api.js b/libs/api.js index 3a433ab50..1fe280408 100644 --- a/libs/api.js +++ b/libs/api.js @@ -15,9 +15,11 @@ module.exports = function(logger, portalConfig, poolConfigs){ this.handleApiRequest = function(req, res, next){ switch(req.params.method){ case 'stats': + res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(portalStats.statsString); return; case 'pool_stats': + res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(portalStats.statPoolHistory)); return; case 'live_stats': @@ -51,4 +53,4 @@ module.exports = function(logger, portalConfig, poolConfigs){ } }; -}; \ No newline at end of file +}; diff --git a/libs/apiCoinWarz.js b/libs/apiCoinWarz.js index 172d2b787..f455f3927 100644 --- a/libs/apiCoinWarz.js +++ b/libs/apiCoinWarz.js @@ -8,7 +8,7 @@ module.exports = function() { // Constants var version = '0.0.1', - PUBLIC_API_URL = 'http://www.coinwarz.com/v1/api/profitability/?apikey=YOUR_API_KEY&algo=all', + PUBLIC_API_URL = 'https://www.coinwarz.com/v1/api/profitability/?apikey=YOUR_API_KEY&algo=all', USER_AGENT = 'nomp/node-open-mining-portal' // Constructor diff --git a/libs/apiCryptsy.js b/libs/apiCryptsy.js index 6563ab5ed..1717afcba 100644 --- a/libs/apiCryptsy.js +++ b/libs/apiCryptsy.js @@ -8,7 +8,7 @@ module.exports = function() { // Constants var version = '0.1.0', - PUBLIC_API_URL = 'http://pubapi.cryptsy.com/api.php', + PUBLIC_API_URL = 'https://pubapi.cryptsy.com/api.php', PRIVATE_API_URL = 'https://api.cryptsy.com/api', USER_AGENT = 'nomp/node-open-mining-portal' diff --git a/libs/mposCompatibility.js b/libs/mposCompatibility.js index 6f044c49d..8d6ed3170 100644 --- a/libs/mposCompatibility.js +++ b/libs/mposCompatibility.js @@ -85,7 +85,7 @@ module.exports = function(logger, poolConfig){ shareData.worker, isValidShare ? 'Y' : 'N', isValidBlock ? 'Y' : 'N', - shareData.difficulty * (poolConfig.coin.mposDiffMultiplier || 1), + shareData.shareDiff, typeof(shareData.error) === 'undefined' ? null : shareData.error, shareData.blockHash ? shareData.blockHash : (shareData.blockHashInvalid ? shareData.blockHashInvalid : '') ]; diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index 30054a3d8..0e5428e47 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -64,21 +64,35 @@ function SetupForPool(logger, poolOptions, setupFinished){ async.parallel([ function(callback){ + if (poolOptions.address != false) { daemon.cmd('validateaddress', [poolOptions.address], function(result) { if (result.error){ logger.error(logSystem, logComponent, 'Error with payment processing daemon ' + JSON.stringify(result.error)); callback(true); } else if (!result.response || !result.response.ismine) { - logger.error(logSystem, logComponent, - 'Daemon does not own pool address - payment processing can not be done with this daemon, ' - + JSON.stringify(result.response)); - callback(true); + daemon.cmd('getaddressinfo', [poolOptions.address], function(result) { + if (result.error){ + logger.error(logSystem, logComponent, 'Error with payment processing daemon, getaddressinfo failed ... ' + JSON.stringify(result.error)); + callback(true); + } + else if (!result.response || !result.response.ismine) { + logger.error(logSystem, logComponent, + 'Daemon does not own pool address - payment processing can not be done with this daemon, ' + + JSON.stringify(result.response)); + callback(true); + } + else{ + callback() + } + }, true); } else{ callback() } }, true); + } + else callback(); }, function(callback){ daemon.cmd('getbalance', [], function(result){ @@ -169,7 +183,7 @@ function SetupForPool(logger, poolOptions, setupFinished){ var workers = {}; for (var w in results[0]){ - workers[w] = {balance: coinsToSatoshies(parseInt(results[0][w]))}; + workers[w] = {balance: coinsToSatoshies(parseFloat(results[0][w]))}; } var rounds = results[1].map(function(r){ @@ -518,12 +532,37 @@ function SetupForPool(logger, poolOptions, setupFinished){ }); }; + function handleAddress(address) { + if (address.length === 40){ + return util.addressFromEx(poolOptions.address, address); + } + else return address; + } var getProperAddress = function(address){ - if (address.length === 40){ - return util.addressFromEx(poolOptions.address, address); - } - else return address; + if (address != false) { + return handleAddress(address); + } else { + var addressToPay = ''; + + daemon.cmd('getnewaddress', [], function(result){ + if (result.error){ + callback(true); + return; + } + try { + addressToPay = result.data; + } + catch(e){ + logger.error(logSystem, logComponent, 'Error getting a new address. Got: ' + result.data); + callback(true); + } + + }, true, true); + + return handleAddress(addressToPay); + + } }; diff --git a/libs/poolWorker.js b/libs/poolWorker.js index d85d01622..ed224c32c 100644 --- a/libs/poolWorker.js +++ b/libs/poolWorker.js @@ -18,6 +18,33 @@ module.exports = function(logger){ var proxySwitch = {}; + var switchingDaemons = (function(){ + var daemons = {}; + + for (var switchName in portalConfig.switching){ + if (!portalConfig.switching[switchName].singleCoinPayout) continue; + var daemonConfig = portalConfig.switching[switchName].singleCoinPayout.daemon; + var daemon = new Stratum.daemon.interface([daemonConfig], function(severity, message){ + logger[severity](logSystem, logComponent, message); + }); + daemons[switchName] = daemon; + } + + return daemons; + })(); + + var singleCoinPayoutPorts = (function(){ + var ports = {}; + for (var switchName in portalConfig.switching){ + if (!portalConfig.switching[switchName].singleCoinPayout) continue; + for (var port in portalConfig.switching[switchName].ports){ + ports[parseInt(port)] = switchName; + } + } + return ports; + })(); + + var redisClient = redis.createClient(portalConfig.redis.port, portalConfig.redis.host); //Handle messages from master process sent via IPC @@ -128,10 +155,13 @@ module.exports = function(logger){ //Functions required for internal payment processing else{ - var shareProcessor = new ShareProcessor(logger, poolOptions); + var shareProcessor = new ShareProcessor(logger, portalConfig, poolOptions, singleCoinPayoutPorts); handlers.auth = function(port, workerName, password, authCallback){ - if (poolOptions.validateWorkerUsername !== true) + + var switchDaemon = switchingDaemons[singleCoinPayoutPorts[port]]; + + if (!switchDaemon && poolOptions.validateWorkerUsername !== true) authCallback(true); else { if (workerName.length === 40) { @@ -144,7 +174,9 @@ module.exports = function(logger){ } } else { - pool.daemon.cmd('validateaddress', [workerName], function (results) { + var daemon = switchDaemon || pool.daemon; + + daemon.cmd('validateaddress', [workerName], function (results) { var isValid = results.filter(function (r) { return r.response.isvalid }).length > 0; @@ -184,12 +216,16 @@ module.exports = function(logger){ logger.debug(logSystem, logComponent, logSubCat, 'We thought a block was found but it was rejected by the daemon, share data: ' + shareData); else if (isValidBlock) - logger.debug(logSystem, logComponent, logSubCat, 'Block found: ' + data.blockHash); + logger.debug(logSystem, logComponent, logSubCat, 'Block found: ' + data.blockHash + ' by ' + data.worker); - if (isValidShare) + if (isValidShare) { + if(data.shareDiff > 1000000000) + logger.debug(logSystem, logComponent, logSubCat, 'Share was found with diff higher than 1.000.000.000!'); + else if(data.shareDiff > 1000000) + logger.debug(logSystem, logComponent, logSubCat, 'Share was found with diff higher than 1.000.000!'); logger.debug(logSystem, logComponent, logSubCat, 'Share accepted at diff ' + data.difficulty + '/' + data.shareDiff + ' by ' + data.worker + ' [' + data.ip + ']' ); - else if (!isValidShare) + } else if (!isValidShare) logger.debug(logSystem, logComponent, logSubCat, 'Share rejected: ' + shareData); handlers.share(isValidShare, isValidBlock, data) @@ -273,7 +309,7 @@ module.exports = function(logger){ if (pools[currentPool]) pools[currentPool].getStratumServer().handleNewClient(socket); else - pools[initialPool].getStratumServer().handleNewClient(socket); + pools[initalPool].getStratumServer().handleNewClient(socket); }).listen(parseInt(port), function() { logger.debug(logSystem, logComponent, logSubCat, 'Switching "' + switchName diff --git a/libs/shareProcessor.js b/libs/shareProcessor.js index 4495a00ca..d9fd1841c 100644 --- a/libs/shareProcessor.js +++ b/libs/shareProcessor.js @@ -15,7 +15,7 @@ value: a hash with.. -module.exports = function(logger, poolConfig){ +module.exports = function(logger, portalConfig, poolConfig, singleCoinPayoutPorts){ var redisConfig = poolConfig.redis; var coin = poolConfig.coin.name; @@ -36,7 +36,7 @@ module.exports = function(logger, poolConfig){ logger.error(logSystem, logComponent, logSubCat, 'Redis client had an error: ' + JSON.stringify(err)) }); connection.on('end', function(){ - logger.error(logSystem, logComponent, logSubCat, 'Connection to redis database as been ended'); + logger.error(logSystem, logComponent, logSubCat, 'Connection to redis database has been ended'); }); connection.info(function(error, response){ @@ -68,10 +68,25 @@ module.exports = function(logger, poolConfig){ this.handleShare = function(isValidShare, isValidBlock, shareData){ + + /*var shareKey = (function(){ + var port = shareData.port.toString(); + for (var switchName in portalConfig.switching){ + if (!portalConfig.switching[switchName]['singleCoinPayout']) continue; + var ports = Object.keys(portalConfig.switching[switchName].ports); + if (ports.indexOf(port) !== -1) return switchName; + } + return coin; + })();*/ + + var shareKey = singleCoinPayoutPorts[shareData.port] || coin; + + // console.log('share key ' + shareKey); + var redisCommands = []; if (isValidShare){ - redisCommands.push(['hincrbyfloat', coin + ':shares:roundCurrent', shareData.worker, shareData.difficulty]); + redisCommands.push(['hincrbyfloat', shareKey + ':shares:roundCurrent', shareData.worker, shareData.difficulty]); redisCommands.push(['hincrby', coin + ':stats', 'validShares', 1]); } else{ diff --git a/libs/stats.js b/libs/stats.js index e12819001..1b22eb959 100644 --- a/libs/stats.js +++ b/libs/stats.js @@ -114,7 +114,7 @@ module.exports = function(logger, portalConfig, poolConfigs){ ['hgetall', ':stats'], ['scard', ':blocksPending'], ['scard', ':blocksConfirmed'], - ['scard', ':blocksOrphaned'] + ['scard', ':blocksKicked'] ]; var commandsPerCoin = redisCommandTemplates.length; @@ -274,9 +274,9 @@ module.exports = function(logger, portalConfig, poolConfigs){ var i = -1; var byteUnits = [ ' KH', ' MH', ' GH', ' TH', ' PH' ]; do { - hashrate = hashrate / 1024; + hashrate = hashrate / 1000; i++; - } while (hashrate > 1024); + } while (hashrate > 1000); return hashrate.toFixed(2) + byteUnits[i]; }; diff --git a/libs/website.js b/libs/website.js index b570c244a..e9e28d96f 100644 --- a/libs/website.js +++ b/libs/website.js @@ -206,7 +206,7 @@ module.exports = function(logger){ }); }; - buildKeyScriptPage(); + // buildKeyScriptPage(); var getPage = function(pageId){ if (pageId in pageProcessed){ @@ -242,9 +242,9 @@ module.exports = function(logger){ next(); }); - app.get('/key.html', function(req, res, next){ - res.end(keyScriptProcessed); - }); + // app.get('/key.html', function(req, res, next){ + // res.end(keyScriptProcessed); + // }); app.get('/:page', route); app.get('/', route); diff --git a/package.json b/package.json index f6467a2a8..8c1263bac 100644 --- a/package.json +++ b/package.json @@ -31,21 +31,21 @@ "url": "https://github.com/zone117x/node-open-mining-portal.git" }, "dependencies": { - "stratum-pool": "git://github.com/zone117x/node-stratum-pool.git", - "dateformat": "*", + "stratum-pool": "cpuchain/node-stratum-pool", + "dateformat": "1.0.12", "node-json-minify": "*", - "redis": "*", + "redis": "0.12.1", "mysql": "*", - "async": "*", + "async": "1.5.2", "express": "*", "body-parser": "*", "compression": "*", "dot": "*", "colors": "*", "node-watch": "*", - "request": "*", + "request": "2.69.0", "nonce": "*", - "bignum": "*", + "bignum": "0.13.0", "extend": "*" }, "engines": { diff --git a/pool_configs/cpuchain_example.json b/pool_configs/cpuchain_example.json new file mode 100644 index 000000000..41ba0a7d8 --- /dev/null +++ b/pool_configs/cpuchain_example.json @@ -0,0 +1,63 @@ +{ + "enabled": false, + "coin": "cpuchain.json", + + "address": "", + + "rewardRecipients": { + "CPUchainWKQfyNBHz5gYPX6J4a5ea9rjWG": 1.0 + }, + + "paymentProcessing": { + "enabled": true, + "paymentInterval": 86400, + "minimumPayment": 0.5, + "daemon": { + "host": "127.0.0.1", + "port": 19707, + "user": "testuser", + "password": "testpass" + } + }, + + "ports": { + "3032": { + "diff": 0.5, + "varDiff": { + "minDiff": 0.00, + "maxDiff": 16, + "targetTime": 15, + "retargetTime": 60, + "variancePercent": 30 + } + } + }, + + "daemons": [ + { + "host": "127.0.0.1", + "port": 19707, + "user": "testuser", + "password": "testpass" + } + ], + + "p2p": { + "enabled": true, + "host": "127.0.0.1", + "port": 19706, + "disableTransactions": true + }, + + "mposMode": { + "enabled": false, + "host": "127.0.0.1", + "port": 3306, + "user": "me", + "password": "mypass", + "database": "cpu", + "checkPassword": true, + "autoCreateWorker": false + } + +} diff --git a/website/index.html b/website/index.html index ea5f47686..4cd727b49 100644 --- a/website/index.html +++ b/website/index.html @@ -6,7 +6,7 @@ - + @@ -76,7 +76,7 @@