Merge branch 'master' of git://github.com/zone117x/node-open-mining-portal into zone117x-master

This commit is contained in:
Eugene@ubuntu 2014-03-27 08:11:41 +04:00
commit 98619910d0
19 changed files with 353 additions and 40 deletions

3
.gitignore vendored
View File

@ -1,3 +1,2 @@
node_modules/
.idea/
pool_configs/
.idea/

View File

@ -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
```

6
coins/galleon.json Normal file
View File

@ -0,0 +1,6 @@
{
"name" : "Galleon",
"symbol" : "GLN",
"algorithm" : "keccak",
"txMessages" : false
}

6
coins/helixcoin.json Normal file
View File

@ -0,0 +1,6 @@
{
"name" : "Helixcoin",
"symbol" : "HXC",
"algorithm" : "max",
"txMessages" : false
}

6
coins/wecoin.json Normal file
View File

@ -0,0 +1,6 @@
{
"name" : "Wecoin",
"symbol" : "WEC",
"algorithm" : "max",
"txMessages" : false
}

View File

@ -20,7 +20,7 @@
"enabled": true,
"siteTitle": "Cryppit",
"port": 80,
"statUpdateInterval": 3,
"statUpdateInterval": 5,
"hashrateWindow": 600
},
"proxy": {

14
init.js
View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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:
<div>Hashrate: {{=stats.hashrate}</div>
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();
});

View File

@ -40,7 +40,8 @@
"async": "*",
"express": "*",
"dot": "*",
"colors": "*"
"colors": "*",
"node-watch": "*"
},
"engines": {
"node": ">=0.10"

View File

@ -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"
}
]
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -1,5 +1,5 @@
<div>
To get started....
To get started simply....
</div>