diff --git a/README.md b/README.md index 237e439..295e2bc 100644 --- a/README.md +++ b/README.md @@ -67,18 +67,24 @@ Installation "stratumPort": 3334, "difficulty": 8, "daemon": { - "bin": "dogecoind", + "host": "localhost", "port": 8332, "user": "test", - "password": "test", - "blocknotify": "blockNotify.js doge %s", - "startIfOffline": true + "password": "test" } } ``` * Supported `"algorithm"` options: `"sha256"` `"scrypt"` `"scrypt-jane"` `"quark"` * Supported `"reward"` options: `"POW"` `"POS"` + * Ensure the `daemon` properties are configured correctly for RPC communication + +* Setting up blocknotify (optional, recommended) + * Inside `config.json` make sure `blockNotifyListener.enabled` is set to true + * Set the `blockNotifyListener.port` and `blockNotifyListener.password` + * Inside your daemon startup parameters or conf file, use `-blocknotify="[path to blockNotify.js] [pool host]:[pool blockNotifyListener port] [blockNotifyListener password] [coin symbole set in coin's json config] %s"` + * Example: `dogecoind -blocknotify="blockNotify.js localhost:8117 mySuperSecurePassword doge %s" + * If your daemon is on a different host you will have to copy the `blockNotify.js` to it * To start the poolserver run: diff --git a/blockNotify.js b/blockNotify.js index 9b78357..a78d66d 100644 --- a/blockNotify.js +++ b/blockNotify.js @@ -2,9 +2,20 @@ var net = require('net'); -var client = net.connect({port: 8124}, function() { +var config = process.argv[1]; +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 client = net.connect(port, host, function() { console.log('client connected'); - client.write(JSON.stringify(process.argv) + '\n'); + client.write(JSON.stringify({ + password: password, + blockHash: blockHash + }) + '\n'); }); client.on('data', function(data) { diff --git a/init.js b/init.js index f1e66a8..e21bd4e 100644 --- a/init.js +++ b/init.js @@ -2,8 +2,6 @@ var net = require('net'); var fs = require('fs'); var path = require('path'); -var bignum = require('bignum'); - var pool = require('./pool.js'); var logRef = console.log; @@ -12,12 +10,15 @@ console.log = function(s){ logRef(time + ': ' + s); }; + +var config = JSON.parse(fs.readFileSync("config.json")); + + function Coin(options){ this.options = options; } Coin.prototype = {}; - var coins = []; var confFolder = 'coins'; @@ -40,20 +41,21 @@ fs.readdir(confFolder, function(err, files){ }); - -var blockNotifyServer = net.createServer(function(c) { - console.log('server connected'); - var data = ''; - c.on('data', function(d){ - console.log('got blocknotify data'); - data += d; - if (data.slice(-1) === '\n'){ - c.end(); - } +if (config.blockNotifyListener.enabled){ + var blockNotifyServer = net.createServer(function(c) { + console.log('server connected'); + var data = ''; + c.on('data', function(d){ + console.log('got blocknotify data'); + data += d; + if (data.slice(-1) === '\n'){ + c.end(); + } + }); + c.on('end', function() { + console.log(data); + console.log('server disconnected'); + }); }); - c.on('end', function() { - console.log(data); - console.log('server disconnected'); - }); -}); -//blockNotifyServer.listen(8124, function() {}); + blockNotifyServer.listen(config.blockNotifyListener.port, function() {}); +}