From 6e72e9392a69b6d8ac5a6c03be8b45e5ea15f10a Mon Sep 17 00:00:00 2001 From: Matthew Little Date: Mon, 13 Jan 2014 18:32:54 -0700 Subject: [PATCH] inital upload --- README.md | 9 +++++++ coins/dogecoin_example.json | 16 +++++++++++++ config.json | 7 ++++++ init.js | 48 +++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 coins/dogecoin_example.json create mode 100644 config.json create mode 100644 init.js diff --git a/README.md b/README.md index e69de29..23b736f 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,9 @@ +* git clone https://github.com/zone117x/node-stratum-portal.git +* npm install stratum-pool +* node init.js + + + +For Development of stratum-pool +=============================== +* symlink node_modules/stratum-pool to development directory \ No newline at end of file diff --git a/coins/dogecoin_example.json b/coins/dogecoin_example.json new file mode 100644 index 0000000..8ef6b21 --- /dev/null +++ b/coins/dogecoin_example.json @@ -0,0 +1,16 @@ +{ + "name": "Dogecoin", + "symbol": "doge", + "algorithm": "scrypt", + "reward": "POW", + "address": "n3s8iDk1onxyY2nuC1k4HoRQFGJ7BhjFcq", + "stratumPort": 3334, + "difficulty": 8, + "blockRefreshInterval": 5, + "daemon": { + "host": "localhost", + "port": 19334, + "user": "testnet", + "password": "testnet1" + } +} diff --git a/config.json b/config.json new file mode 100644 index 0000000..feffc01 --- /dev/null +++ b/config.json @@ -0,0 +1,7 @@ +{ + "blockNotifyListener": { + "enabled": false, + "port": 8117, + "password": "test" + } +} \ No newline at end of file diff --git a/init.js b/init.js new file mode 100644 index 0000000..001f251 --- /dev/null +++ b/init.js @@ -0,0 +1,48 @@ +var fs = require('fs'); + +var Stratum = require('stratum-pool'); + + + +var timeLog = function(text, poolName){ + var desc = poolName ? '[' + poolName + '] ' : ''; + var time = new Date().toISOString(); + console.log(time + ': ' + desc + text); +}; + +var config = JSON.parse(fs.readFileSync("config.json")); + + +var stratum = new Stratum(config); +stratum.on('log', function(logText){ + timeLog(logText); +}); + + +fs.readdirSync('coins').forEach(function(file){ + + var coinOptions = JSON.parse(fs.readFileSync('coins/' + file, {encoding: 'utf8'})); + + var authorizeFN = function (ip, workerName, password, callback) { + // Default implementation just returns true + timeLog(coinOptions.name, "Authorize ["+ip+"] "+workerName+":"+password); + callback({ + error: null, + authorized: true, + disconnect: false + }); + }; + + + var pool = stratum.createPool(coinOptions, authorizeFN); + pool.on('share', function(isValid, data){ + if (isValid) + timeLog(coinOptions.name, "A new Valid share from " + data.client.workerName + " has arrived! - " + data.headerHex); + else + timeLog(coinOptions.name, "Invalid share form " + data.client.workerName + " ErrorCode: " + data.errorCode + " ErrorDescription: " + data.errorDescription); + }).on('log', function(logText){ + timeLog(coinOptions.name, logText); + }); + +}); +