diff --git a/.gitignore b/.gitignore index ccd8331..d35bbf7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ node_modules/ -.idea/ -pool_configs/ \ No newline at end of file +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 4b6995b..cb9736c 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,8 @@ config directory and coin.conf file. For more info on this see: Clone the repository and run `npm update` for all the dependencies to be installed: ```bash -git clone https://github.com/zone117x/node-stratum-portal.git +git clone https://github.com/zone117x/node-stratum-portal.git nomp +cd nomp npm update ``` diff --git a/coins/galleon.json b/coins/galleon.json new file mode 100644 index 0000000..53c6a2b --- /dev/null +++ b/coins/galleon.json @@ -0,0 +1,6 @@ +{ + "name" : "Galleon", + "symbol" : "GLN", + "algorithm" : "keccak", + "txMessages" : false +} \ No newline at end of file diff --git a/coins/helixcoin.json b/coins/helixcoin.json new file mode 100644 index 0000000..2ae867b --- /dev/null +++ b/coins/helixcoin.json @@ -0,0 +1,6 @@ +{ + "name" : "Helixcoin", + "symbol" : "HXC", + "algorithm" : "max", + "txMessages" : false +} \ No newline at end of file diff --git a/coins/wecoin.json b/coins/wecoin.json new file mode 100644 index 0000000..cdac3d3 --- /dev/null +++ b/coins/wecoin.json @@ -0,0 +1,6 @@ +{ + "name" : "Wecoin", + "symbol" : "WEC", + "algorithm" : "max", + "txMessages" : false +} \ No newline at end of file diff --git a/config.json b/config.json index ec88df7..f602d64 100644 --- a/config.json +++ b/config.json @@ -20,7 +20,7 @@ "enabled": true, "siteTitle": "Cryppit", "port": 80, - "statUpdateInterval": 3, + "statUpdateInterval": 5, "hashrateWindow": 600 }, "proxy": { diff --git a/init.js b/init.js index 4b7870b..972f554 100644 --- a/init.js +++ b/init.js @@ -179,6 +179,20 @@ var startRedisBlockListener = function(portalConfig){ var startPaymentProcessor = function(poolConfigs){ + + var enabledForAny = false; + for (var pool in poolConfigs){ + var p = poolConfigs[pool]; + var enabled = p.shareProcessing && p.shareProcessing.internal && p.shareProcessing.internal.enabled; + if (enabled){ + enabledForAny = true; + break; + } + } + + if (!enabledForAny) + return; + var worker = cluster.fork({ workerType: 'paymentProcessor', pools: JSON.stringify(poolConfigs) diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index 4114205..1e75c35 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -19,11 +19,16 @@ module.exports = function(logger){ function SetupForPool(logger, poolOptions){ - var coin = poolOptions.coin.name; + if (!poolOptions.shareProcessing || + poolOptions.shareProcessing.internal || + !poolOptions.shareProcessing.internal.enabled) + return; + + var coin = poolOptions.coin.name; var processingConfig = poolOptions.shareProcessing.internal; - if (!processingConfig.enabled) return; + var logSystem = 'Payments'; var logComponent = coin; diff --git a/libs/poolWorker.js b/libs/poolWorker.js index dd39636..8706fe8 100644 --- a/libs/poolWorker.js +++ b/libs/poolWorker.js @@ -64,7 +64,7 @@ module.exports = function(logger){ var shareProcessing = poolOptions.shareProcessing; //Functions required for MPOS compatibility - if (shareProcessing.mpos && shareProcessing.mpos.enabled){ + if (shareProcessing && shareProcessing.mpos && shareProcessing.mpos.enabled){ var mposCompat = new MposCompatibility(logger, poolOptions) handlers.auth = function(workerName, password, authCallback){ @@ -81,7 +81,7 @@ module.exports = function(logger){ } //Functions required for internal payment processing - else if (shareProcessing.internal && shareProcessing.internal.enabled){ + else if (shareProcessing && shareProcessing.internal && shareProcessing.internal.enabled){ var shareProcessor = new ShareProcessor(logger, poolOptions) diff --git a/libs/stats.js b/libs/stats.js index 177c82a..87277b4 100644 --- a/libs/stats.js +++ b/libs/stats.js @@ -8,6 +8,8 @@ module.exports = function(logger, portalConfig, poolConfigs){ var _this = this; + var logSystem = 'Stats'; + var redisClients = []; var algoMultipliers = { @@ -17,8 +19,20 @@ module.exports = function(logger, portalConfig, poolConfigs){ 'sha256': Math.pow(2, 32) }; + var canDoStats = true; + Object.keys(poolConfigs).forEach(function(coin){ + + if (!canDoStats) return; + var poolConfig = poolConfigs[coin]; + + if (!poolConfig.shareProcessing || !poolConfig.shareProcessing.internal){ + logger.error(logSystem, coin, 'Cannot do stats without internal share processing setup'); + canDoStats = false; + return; + } + var internalConfig = poolConfig.shareProcessing.internal; var redisConfig = internalConfig.redis; @@ -125,10 +139,10 @@ module.exports = function(logger, portalConfig, poolConfigs){ var shareMultiplier = algoMultipliers[coinStats.algorithm]; var hashratePre = shareMultiplier * coinStats.shares / portalConfig.website.hashrateWindow; coinStats.hashrate = hashratePre / 1e3 | 0; - delete coinStats.hashrates; - delete coinStats.shares; portalStats.global.hashrate += coinStats.hashrate; portalStats.global.workers += Object.keys(coinStats.workers).length; + delete coinStats.hashrates; + delete coinStats.shares; }); _this.stats = portalStats; diff --git a/libs/website.js b/libs/website.js index 5e6cbfe..d4ea491 100644 --- a/libs/website.js +++ b/libs/website.js @@ -1,28 +1,3 @@ -/* TODO - - -Need to condense the entire website into a single html page. Embedding the javascript and css is easy. For images, -hopefully we can only use svg which can be embedded - otherwise we can convert the image into a data-url that can -be embedded, Favicon can also be a data-url which some javascript kungfu can display in browser. I'm focusing on -this mainly to help mitigate ddos and other kinds of attacks - and to just have a badass blazing fast project. - -Don't worry about doing any of that condensing yourself - go head and keep all the resources as separate files. -I will write a script for when the server starts to read all the files in the /website folder and minify and condense -it all together into one file, saved in memory. We will have 1 persistent condensed file that servers as our "template" -file that contains things like: -
Hashrate: {{=stats.hashrate}
- -And then on some caching interval (maybe 5 seconds?) we will apply the template engine to generate the real html page -that we serve and hold in in memory - this is the file we serve to seo-bots (googlebot) and users when they first load -the page. - -Once the user loads the page we will have server-side event source connected to the portal api where it receives -updated stats on some interval (probably 5 seconds like template cache updater) and applies the changes to the already -displayed page. - -We will use fs.watch to detect changes to anything in the /website folder and update our stuff in memory. - - */ var fs = require('fs'); var path = require('path'); @@ -31,6 +6,8 @@ var async = require('async'); var dot = require('dot'); var express = require('express'); +var watch = require('node-watch'); + var api = require('./api.js'); @@ -78,7 +55,8 @@ module.exports = function(logger){ portalConfig: portalConfig }); } - logger.debug(logSystem, 'Stats', 'Website updated to latest stats'); + + //logger.debug(logSystem, 'Stats', 'Website updated to latest stats'); }; @@ -101,8 +79,9 @@ module.exports = function(logger){ - fs.watch('website', function(event, filename){ - if (event === 'change' && filename in pageFiles) + watch('website', function(filename){ + //if (event === 'change' && filename in pageFiles) + //READ ALL THE FILEZ BLAHHH readPageFiles(); }); diff --git a/package.json b/package.json index c63ae63..5ebd0ec 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "async": "*", "express": "*", "dot": "*", - "colors": "*" + "colors": "*", + "node-watch": "*" }, "engines": { "node": ">=0.10" diff --git a/pool_configs/darkcoin_example.json b/pool_configs/darkcoin_example.json new file mode 100644 index 0000000..0ab86a5 --- /dev/null +++ b/pool_configs/darkcoin_example.json @@ -0,0 +1,64 @@ +{ + "disabled": true, + "coin": "darkcoin.json", + + "shareProcessing": { + "internal": { + "enabled": true, + "validateWorkerAddress": true, + "paymentInterval": 10, + "minimumPayment": 100.001, + "minimumReserve": 10, + "feePercent": 0.02, + "feeReceiveAddress": "XfkoYutJ8KYtLxZ4TgnMqC6SCmxuc3LEDY", + "feeWithdrawalThreshold": 5, + "daemon": { + "host": "localhost", + "port": 18342, + "user": "darkcoinrpc1", + "password": "testpass" + }, + "redis": { + "host": "localhost", + "port": 6379 + } + }, + "mpos": { + "enabled": false, + "host": "localhost", + "port": 3306, + "user": "me", + "password": "mypass", + "database": "ltc", + "stratumAuth": "password" + } + }, + + "address": "XfkoYutJ8KYtLxZ4TgnMqC6SCmxuc3LEDY", + "blockRefreshInterval": 1000, + "txRefreshInterval": 20000, + "connectionTimeout": 600, + + "banning": { + "enabled": true, + "time": 600, + "invalidPercent": 50, + "checkThreshold": 500, + "purgeInterval": 300 + }, + + "ports": { + "4073": { + "diff": 0.002 + } + }, + + "daemons": [ + { + "host": "localhost", + "port": 18342, + "user": "darkcoinrpc1", + "password": "testpass" + } + ] +} \ No newline at end of file diff --git a/pool_configs/galleon_example.json b/pool_configs/galleon_example.json new file mode 100644 index 0000000..470361a --- /dev/null +++ b/pool_configs/galleon_example.json @@ -0,0 +1,55 @@ +{ + "disabled": false, + "coin": "galleon.json", + + "address": "GRAiuGCWLrL8Psdr6pkhLpxrQGHdYfrSEz", + "blockRefreshInterval": 1000, + "txRefreshInterval": 20000, + "connectionTimeout": 600, + + "shareProcessing": { + "internal": { + "enabled": true, + "validateWorkerAddress": true, + "paymentInterval": 10, + "minimumPayment": 100.001, + "minimumReserve": 10, + "feePercent": 0.02, + "feeReceiveAddress": "GRAiuGCWLrL8Psdr6pkhLpxrQGHdYfrSEz", + "feeWithdrawalThreshold": 5, + "daemon": { + "host": "localhost", + "port": 19632, + "user": "testuser", + "password": "testpass" + }, + "redis": { + "host": "localhost", + "port": 6379 + } + } + }, + + "ports": { + "3537": { + "diff": 4 + } + }, + + "daemons": [ + { + "host": "localhost", + "port": 19632, + "user": "testuser", + "password": "testpass" + } + ], + + "p2p": { + "enabled": false, + "host": "localhost", + "port": 19333, + "protocolVersion": 70002, + "magic": "fcc1b7dc" + } +} \ No newline at end of file diff --git a/pool_configs/helixcoin_example.json b/pool_configs/helixcoin_example.json new file mode 100644 index 0000000..75f412c --- /dev/null +++ b/pool_configs/helixcoin_example.json @@ -0,0 +1,33 @@ +{ + "disabled": true, + "coin": "helixcoin.json", + + "address": "H9xyrh45LzLX4uXCP6jG6ZGrWho8srUgiG", + "blockRefreshInterval": 1000, + "txRefreshInterval": 20000, + "connectionTimeout": 600, + + + "ports": { + "3737": { + "diff": 0.2 + } + }, + + "daemons": [ + { + "host": "localhost", + "port": 16385, + "user": "testuser", + "password": "testpass" + } + ], + + "p2p": { + "enabled": false, + "host": "localhost", + "port": 19333, + "protocolVersion": 70002, + "magic": "fcc1b7dc" + } +} \ No newline at end of file diff --git a/pool_configs/hirocoin_example.json b/pool_configs/hirocoin_example.json new file mode 100644 index 0000000..295065a --- /dev/null +++ b/pool_configs/hirocoin_example.json @@ -0,0 +1,65 @@ +{ + "disabled": true, + "coin": "hirocoin.json", + + "shareProcessing": { + "internal": { + "enabled": true, + "validateWorkerAddress": true, + "paymentInterval": 10, + "minimumPayment": 100.001, + "minimumReserve": 10, + "feePercent": 0.02, + "feeReceiveAddress": "HR6WNSR19kvaXSbwKymrba6uNx36BBjinS", + "feeWithdrawalThreshold": 5, + "daemon": { + "host": "localhost", + "port": 19389, + "user": "hirocoin", + "password": "testpass" + }, + "redis": { + "host": "localhost", + "port": 6379 + } + }, + "mpos": { + "enabled": false, + "host": "localhost", + "port": 3306, + "user": "me", + "password": "mypass", + "database": "ltc", + "stratumAuth": "password" + } + }, + + + "address": "HR6WNSR19kvaXSbwKymrba6uNx36BBjinS", + "blockRefreshInterval": 1000, + "txRefreshInterval": 20000, + "connectionTimeout": 600, + + "banning": { + "enabled": true, + "time": 600, + "invalidPercent": 50, + "checkThreshold": 500, + "purgeInterval": 300 + }, + + "ports": { + "3073": { + "diff": 0.002 + } + }, + + "daemons": [ + { + "host": "localhost", + "port": 19389, + "user": "hirocoin", + "password": "testpass" + } + ] +} \ No newline at end of file diff --git a/pool_configs/hobonickels_example.json b/pool_configs/hobonickels_example.json new file mode 100644 index 0000000..144fd24 --- /dev/null +++ b/pool_configs/hobonickels_example.json @@ -0,0 +1,65 @@ +{ + "disabled": true, + "coin": "hobonickels.json", + + "shareProcessing": { + "internal": { + "enabled": true, + "validateWorkerAddress": true, + "paymentInterval": 10, + "minimumPayment": 100.001, + "minimumReserve": 10, + "feePercent": 0.02, + "feeReceiveAddress": "EhA4HXF7VPWfnV8TXerAP6p12BiEpXbiYR", + "feeWithdrawalThreshold": 5, + "daemon": { + "host": "localhost", + "port": 19339, + "user": "hobonickelsrpc", + "password": "testpass" + }, + "redis": { + "host": "localhost", + "port": 6379 + } + }, + "mpos": { + "enabled": false, + "host": "localhost", + "port": 3306, + "user": "me", + "password": "mypass", + "database": "ltc", + "stratumAuth": "password" + } + }, + + + "address": "EzGiarU2S56jyRkYpS7FKssXCS6AAJChdU", + "blockRefreshInterval": 1000, + "txRefreshInterval": 20000, + "connectionTimeout": 600, + + "banning": { + "enabled": true, + "time": 600, + "invalidPercent": 50, + "checkThreshold": 500, + "purgeInterval": 300 + }, + + "ports": { + "3033": { + "diff": 8 + } + }, + + "daemons": [ + { + "host": "localhost", + "port": 19339, + "user": "hobonickelsrpc", + "password": "testpass" + } + ] +} \ No newline at end of file diff --git a/pool_configs/litecoin_testnet_example.json b/pool_configs/litecoin_example.json similarity index 100% rename from pool_configs/litecoin_testnet_example.json rename to pool_configs/litecoin_example.json diff --git a/website/pages/getting_started.html b/website/pages/getting_started.html index daf9fd0..e228dc7 100644 --- a/website/pages/getting_started.html +++ b/website/pages/getting_started.html @@ -1,5 +1,5 @@
- To get started.... + To get started simply....
\ No newline at end of file