From 82844687ac6a53e720fc7f3f30b835f247d09168 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 25 Mar 2014 12:52:11 -0600 Subject: [PATCH 1/3] Fixed blockNotify.js script which was using wrong indexes for arguments. --- coins/bitcoin.json | 2 +- coins/darkcoin.json | 2 +- coins/hirocoin.json | 6 ++++++ coins/peercoin.json | 2 +- coins/quarkcoin.json | 2 +- coins/skeincoin.json | 2 +- coins/yacoin.json | 2 +- libs/stats.js | 2 +- scripts/blockNotify.js | 8 ++++---- 9 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 coins/hirocoin.json diff --git a/coins/bitcoin.json b/coins/bitcoin.json index e3870ef..93b1061 100644 --- a/coins/bitcoin.json +++ b/coins/bitcoin.json @@ -1,6 +1,6 @@ { "name": "Bitcoin", - "symbol": "btc", + "symbol": "BTC", "algorithm": "sha256", "txMessages": false } \ No newline at end of file diff --git a/coins/darkcoin.json b/coins/darkcoin.json index 3120964..cb970d5 100644 --- a/coins/darkcoin.json +++ b/coins/darkcoin.json @@ -1,6 +1,6 @@ { "name": "Darkcoin", - "symbol": "drk", + "symbol": "DRK", "algorithm": "x11", "txMessages": false } \ No newline at end of file diff --git a/coins/hirocoin.json b/coins/hirocoin.json new file mode 100644 index 0000000..197d366 --- /dev/null +++ b/coins/hirocoin.json @@ -0,0 +1,6 @@ +{ + "name": "Hirocoin", + "symbol": "hic", + "algorithm": "x11", + "txMessages": false +} \ No newline at end of file diff --git a/coins/peercoin.json b/coins/peercoin.json index 428bbad..12470ed 100644 --- a/coins/peercoin.json +++ b/coins/peercoin.json @@ -1,6 +1,6 @@ { "name": "Peercoin", - "symbol": "ppc", + "symbol": "PPC", "algorithm": "sha256", "txMessages": false } \ No newline at end of file diff --git a/coins/quarkcoin.json b/coins/quarkcoin.json index 597aeb3..084ae78 100644 --- a/coins/quarkcoin.json +++ b/coins/quarkcoin.json @@ -1,6 +1,6 @@ { "name": "Quarkcoin", - "symbol": "qrk", + "symbol": "QRK", "algorithm": "quark", "txMessages": false } \ No newline at end of file diff --git a/coins/skeincoin.json b/coins/skeincoin.json index 31479be..283834d 100644 --- a/coins/skeincoin.json +++ b/coins/skeincoin.json @@ -1,6 +1,6 @@ { "name": "Skeincoin", - "symbol": "skc", + "symbol": "SKC", "algorithm": "skein", "txMessages": false } \ No newline at end of file diff --git a/coins/yacoin.json b/coins/yacoin.json index 932d8ce..8f2f03f 100644 --- a/coins/yacoin.json +++ b/coins/yacoin.json @@ -1,6 +1,6 @@ { "name": "Yacoin", - "symbol": "yac", + "symbol": "YAC", "algorithm": "scrypt-jane", "txMessages": false } \ No newline at end of file diff --git a/libs/stats.js b/libs/stats.js index 87062e7..eb42833 100644 --- a/libs/stats.js +++ b/libs/stats.js @@ -76,7 +76,7 @@ module.exports = function(logger, portalConfig, poolConfigs){ var coinName = client.coins[i / commandsPerCoin | 0]; var coinStats = { name: coinName, - symbol: poolConfigs[coinName].coin.symbol, + symbol: poolConfigs[coinName].coin.symbol.toUpperCase(), algorithm: poolConfigs[coinName].coin.algorithm, hashrates: replies[i + 1], poolStats: replies[i + 2], diff --git a/scripts/blockNotify.js b/scripts/blockNotify.js index ea61d2c..f43dd0f 100644 --- a/scripts/blockNotify.js +++ b/scripts/blockNotify.js @@ -7,13 +7,13 @@ This script will then send the blockhash along with other information to a liste */ var net = require('net'); -var config = process.argv[1]; +var config = process.argv[2]; var parts = config.split(':'); var host = parts[0]; var port = parts[1]; -var password = process.argv[2]; -var coin = process.argv[3]; -var blockHash = process.argv[4]; +var password = process.argv[3]; +var coin = process.argv[4]; +var blockHash = process.argv[5]; var client = net.connect(port, host, function() { console.log('client connected'); From 72c26213a19451b971b1a19203cad233bed52f09 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 25 Mar 2014 16:21:17 -0600 Subject: [PATCH 2/3] Updated git info for node-stratum-pool and refactored website/api structure. --- README.md | 6 +-- libs/api.js | 40 +++++++++++++++- libs/stats.js | 4 +- libs/website.js | 53 +++++++--------------- package.json | 2 +- pool_configs/litecoin_testnet_example.json | 2 +- website/static/main.js | 2 +- 7 files changed, 64 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 46b967a..4b6995b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ front-end website. #### Features -* For the pool server it uses the highly efficient [node-stratum](https://github.com/zone117x/node-stratum) module which +* For the pool server it uses the highly efficient [node-stratum-pool](https://github.com/zone117x/node-stratum-pool) module which supports vardiff, POW & POS, transaction messages, anti-DDoS, IP banning, several hashing algorithms. * The portal has an [MPOS](https://github.com/MPOS/php-mpos) compatibility mode so that the it can @@ -328,7 +328,7 @@ Description of options: You can create as many of these pool config files as you want (such as one pool per coin you which to operate). If you are creating multiple pools, ensure that they have unique stratum ports. -For more information on these configuration options see the [pool module documentation](https://github.com/zone117x/node-stratum#module-usage) +For more information on these configuration options see the [pool module documentation](https://github.com/zone117x/node-stratum-pool#module-usage) @@ -373,7 +373,7 @@ Credits ------- * [vekexasia](https://github.com/vekexasia) - co-developer & great tester * [TheSeven](https://github.com/TheSeven) - answering an absurd amount of my questions and being a very helpful gentleman -* Those that contributed to [node-stratum](/zone117x/node-stratum) +* Those that contributed to [node-stratum-pool](/zone117x/node-stratum-pool) License diff --git a/libs/api.js b/libs/api.js index 84636c4..092d9b8 100644 --- a/libs/api.js +++ b/libs/api.js @@ -1 +1,39 @@ -//create the stats object in here. then let the website use this object. that way we can have a config for stats and website separate :D \ No newline at end of file +var redis = require('redis'); +var async = require('async'); + +var stats = require('./stats.js'); + +module.exports = function(logger, portalConfig, poolConfigs){ + + + var _this = this; + + var portalStats = this.stats = new stats(logger, portalConfig, poolConfigs); + + this.liveStatConnections = {}; + + this.handleApiRequest = function(req, res, next){ + switch(req.params.method){ + case 'stats': + res.end(portalStats.statsString); + return; + case 'live_stats': + res.writeHead(200, { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache', + 'Connection': 'keep-alive' + }); + res.write('\n'); + var uid = Math.random().toString(); + _this.liveStatConnections[uid] = res; + req.on("close", function() { + delete _this.liveStatConnections[uid]; + }); + + return; + default: + next(); + } + }; + +}; \ No newline at end of file diff --git a/libs/stats.js b/libs/stats.js index eb42833..177c82a 100644 --- a/libs/stats.js +++ b/libs/stats.js @@ -11,7 +11,9 @@ module.exports = function(logger, portalConfig, poolConfigs){ var redisClients = []; var algoMultipliers = { + 'x11': Math.pow(2, 16), 'scrypt': Math.pow(2, 16), + 'scrypt-jane': Math.pow(2,16), 'sha256': Math.pow(2, 32) }; @@ -38,7 +40,7 @@ module.exports = function(logger, portalConfig, poolConfigs){ this.statsString = ''; - this.getStats = function(callback){ + this.getGlobalStats = function(callback){ var allCoinStats = {}; diff --git a/libs/website.js b/libs/website.js index a018fcf..5e6cbfe 100644 --- a/libs/website.js +++ b/libs/website.js @@ -31,7 +31,7 @@ var async = require('async'); var dot = require('dot'); var express = require('express'); -var stats = require('./stats.js'); +var api = require('./api.js'); module.exports = function(logger){ @@ -41,7 +41,8 @@ module.exports = function(logger){ var websiteConfig = portalConfig.website; - var portalStats = new stats(logger, portalConfig, poolConfigs); + var portalApi = new api(logger, portalConfig, poolConfigs); + var portalStats = portalApi.stats; var logSystem = 'Website'; @@ -106,17 +107,17 @@ module.exports = function(logger){ }); - portalStats.getStats(function(){ + portalStats.getGlobalStats(function(){ readPageFiles(Object.keys(pageFiles)); }); var buildUpdatedWebsite = function(){ - portalStats.getStats(function(){ + portalStats.getGlobalStats(function(){ processTemplates(); var statData = 'data: ' + JSON.stringify(portalStats.stats) + '\n\n'; - for (var uid in liveStatConnections){ - var res = liveStatConnections[uid]; + for (var uid in portalApi.liveStatConnections){ + var res = portalApi.liveStatConnections[uid]; res.write(statData); } @@ -146,43 +147,21 @@ module.exports = function(logger){ }; - var liveStatConnections = {}; + app.get('/get_page', function(req, res, next){ + var requestedPage = getPage(req.query.id); + if (requestedPage){ + res.end(requestedPage); + return; + } + next(); + }); app.get('/:page', route); app.get('/', route); app.get('/api/:method', function(req, res, next){ - - switch(req.params.method){ - case 'get_page': - var requestedPage = getPage(req.query.id); - if (requestedPage){ - res.end(requestedPage); - return; - } - case 'stats': - res.end(portalStats.statsString); - return; - case 'live_stats': - res.writeHead(200, { - 'Content-Type': 'text/event-stream', - 'Cache-Control': 'no-cache', - 'Connection': 'keep-alive' - }); - res.write('\n'); - var uid = Math.random().toString(); - liveStatConnections[uid] = res; - req.on("close", function() { - delete liveStatConnections[uid]; - }); - - return; - default: - next(); - } - - //res.send('you did api method ' + req.params.method); + portalApi.handleApiRequest(req, res, next); }); app.use('/static', express.static('website/static')); diff --git a/package.json b/package.json index af44f45..c63ae63 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "url": "https://github.com/zone117x/node-open-mining-portal.git" }, "dependencies": { - "stratum-pool": "https://github.com/zone117x/node-stratum/archive/master.tar.gz", + "stratum-pool": "https://github.com/zone117x/node-stratum-pool/archive/master.tar.gz", "dateformat": "*", "node-json-minify": "*", "posix": "*", diff --git a/pool_configs/litecoin_testnet_example.json b/pool_configs/litecoin_testnet_example.json index 1c73847..ba66286 100644 --- a/pool_configs/litecoin_testnet_example.json +++ b/pool_configs/litecoin_testnet_example.json @@ -60,7 +60,7 @@ } }, "3032": { - "diff": 32 + "diff": 16 }, "3256": { "diff": 256 diff --git a/website/static/main.js b/website/static/main.js index df5c7d7..a87d63e 100644 --- a/website/static/main.js +++ b/website/static/main.js @@ -5,7 +5,7 @@ $(function(){ if (pushSate) history.pushState(null, null, '/' + page); $('.selected').removeClass('selected'); $('a[href="/' + page + '"]').parent().addClass('selected') - $.get("/api/get_page", {id: page}, function(data){ + $.get("/get_page", {id: page}, function(data){ $('#page').html(data); }, 'html') }; From 572a5ea45b45bdb6267159c158e610cf850c9c27 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 25 Mar 2014 16:41:30 -0600 Subject: [PATCH 3/3] Typo with error message on tx error --- libs/paymentProcessor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index b0b391e..3b5c0ac 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -121,7 +121,7 @@ function SetupForPool(logger, poolOptions){ txDetails = txDetails.filter(function(tx){ if (tx.error || !tx.result){ - logger.error(logSystem, logComponent, 'error with requesting transaction from block daemon: ' + JSON.stringify(t)); + logger.error(logSystem, logComponent, 'error with requesting transaction from block daemon: ' + JSON.stringify(tx)); return false; } return true;