Merge pull request #1 from zone117x/master

merge last fixes
This commit is contained in:
UdjinM6 2014-03-26 01:48:00 +03:00
commit 8d939776d4
16 changed files with 82 additions and 57 deletions

View File

@ -7,7 +7,7 @@ front-end website.
#### Features #### 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. 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 * 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). 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. 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 * [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 * [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 License

View File

@ -1,6 +1,6 @@
{ {
"name": "Bitcoin", "name": "Bitcoin",
"symbol": "btc", "symbol": "BTC",
"algorithm": "sha256", "algorithm": "sha256",
"txMessages": false "txMessages": false
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Darkcoin", "name": "Darkcoin",
"symbol": "drk", "symbol": "DRK",
"algorithm": "x11", "algorithm": "x11",
"txMessages": false "txMessages": false
} }

6
coins/hirocoin.json Normal file
View File

@ -0,0 +1,6 @@
{
"name": "Hirocoin",
"symbol": "hic",
"algorithm": "x11",
"txMessages": false
}

View File

@ -1,6 +1,6 @@
{ {
"name": "Peercoin", "name": "Peercoin",
"symbol": "ppc", "symbol": "PPC",
"algorithm": "sha256", "algorithm": "sha256",
"txMessages": false "txMessages": false
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Quarkcoin", "name": "Quarkcoin",
"symbol": "qrk", "symbol": "QRK",
"algorithm": "quark", "algorithm": "quark",
"txMessages": false "txMessages": false
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Skeincoin", "name": "Skeincoin",
"symbol": "skc", "symbol": "SKC",
"algorithm": "skein", "algorithm": "skein",
"txMessages": false "txMessages": false
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Yacoin", "name": "Yacoin",
"symbol": "yac", "symbol": "YAC",
"algorithm": "scrypt-jane", "algorithm": "scrypt-jane",
"txMessages": false "txMessages": false
} }

View File

@ -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 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();
}
};
};

View File

@ -121,7 +121,7 @@ function SetupForPool(logger, poolOptions){
txDetails = txDetails.filter(function(tx){ txDetails = txDetails.filter(function(tx){
if (tx.error || !tx.result){ 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 false;
} }
return true; return true;

View File

@ -11,7 +11,9 @@ module.exports = function(logger, portalConfig, poolConfigs){
var redisClients = []; var redisClients = [];
var algoMultipliers = { var algoMultipliers = {
'x11': Math.pow(2, 16),
'scrypt': Math.pow(2, 16), 'scrypt': Math.pow(2, 16),
'scrypt-jane': Math.pow(2,16),
'sha256': Math.pow(2, 32) 'sha256': Math.pow(2, 32)
}; };
@ -38,7 +40,7 @@ module.exports = function(logger, portalConfig, poolConfigs){
this.statsString = ''; this.statsString = '';
this.getStats = function(callback){ this.getGlobalStats = function(callback){
var allCoinStats = {}; var allCoinStats = {};
@ -76,7 +78,7 @@ module.exports = function(logger, portalConfig, poolConfigs){
var coinName = client.coins[i / commandsPerCoin | 0]; var coinName = client.coins[i / commandsPerCoin | 0];
var coinStats = { var coinStats = {
name: coinName, name: coinName,
symbol: poolConfigs[coinName].coin.symbol, symbol: poolConfigs[coinName].coin.symbol.toUpperCase(),
algorithm: poolConfigs[coinName].coin.algorithm, algorithm: poolConfigs[coinName].coin.algorithm,
hashrates: replies[i + 1], hashrates: replies[i + 1],
poolStats: replies[i + 2], poolStats: replies[i + 2],

View File

@ -31,7 +31,7 @@ var async = require('async');
var dot = require('dot'); var dot = require('dot');
var express = require('express'); var express = require('express');
var stats = require('./stats.js'); var api = require('./api.js');
module.exports = function(logger){ module.exports = function(logger){
@ -41,7 +41,8 @@ module.exports = function(logger){
var websiteConfig = portalConfig.website; 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'; var logSystem = 'Website';
@ -106,17 +107,17 @@ module.exports = function(logger){
}); });
portalStats.getStats(function(){ portalStats.getGlobalStats(function(){
readPageFiles(Object.keys(pageFiles)); readPageFiles(Object.keys(pageFiles));
}); });
var buildUpdatedWebsite = function(){ var buildUpdatedWebsite = function(){
portalStats.getStats(function(){ portalStats.getGlobalStats(function(){
processTemplates(); processTemplates();
var statData = 'data: ' + JSON.stringify(portalStats.stats) + '\n\n'; var statData = 'data: ' + JSON.stringify(portalStats.stats) + '\n\n';
for (var uid in liveStatConnections){ for (var uid in portalApi.liveStatConnections){
var res = liveStatConnections[uid]; var res = portalApi.liveStatConnections[uid];
res.write(statData); 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('/:page', route);
app.get('/', route); app.get('/', route);
app.get('/api/:method', function(req, res, next){ app.get('/api/:method', function(req, res, next){
portalApi.handleApiRequest(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);
}); });
app.use('/static', express.static('website/static')); app.use('/static', express.static('website/static'));

View File

@ -31,7 +31,7 @@
"url": "https://github.com/zone117x/node-open-mining-portal.git" "url": "https://github.com/zone117x/node-open-mining-portal.git"
}, },
"dependencies": { "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": "*", "dateformat": "*",
"node-json-minify": "*", "node-json-minify": "*",
"posix": "*", "posix": "*",

View File

@ -60,7 +60,7 @@
} }
}, },
"3032": { "3032": {
"diff": 32 "diff": 16
}, },
"3256": { "3256": {
"diff": 256 "diff": 256

View File

@ -7,13 +7,13 @@ This script will then send the blockhash along with other information to a liste
*/ */
var net = require('net'); var net = require('net');
var config = process.argv[1]; var config = process.argv[2];
var parts = config.split(':'); var parts = config.split(':');
var host = parts[0]; var host = parts[0];
var port = parts[1]; var port = parts[1];
var password = process.argv[2]; var password = process.argv[3];
var coin = process.argv[3]; var coin = process.argv[4];
var blockHash = process.argv[4]; var blockHash = process.argv[5];
var client = net.connect(port, host, function() { var client = net.connect(port, host, function() {
console.log('client connected'); console.log('client connected');

View File

@ -5,7 +5,7 @@ $(function(){
if (pushSate) history.pushState(null, null, '/' + page); if (pushSate) history.pushState(null, null, '/' + page);
$('.selected').removeClass('selected'); $('.selected').removeClass('selected');
$('a[href="/' + page + '"]').parent().addClass('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); $('#page').html(data);
}, 'html') }, 'html')
}; };