diff --git a/lib/pool.js b/lib/pool.js index f50dbd3..70dad11 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -43,6 +43,7 @@ var pool = module.exports = function pool(options, authorizeFn){ var emitLog = function(text) { _this.emit('log', 'debug' , text); }; var emitWarningLog = function(text) { _this.emit('log', 'warning', text); }; var emitErrorLog = function(text) { _this.emit('log', 'error' , text); }; + var emitSpecialLog = function(text) { _this.emit('log', 'special', text); }; //Which number to use as dividend when converting difficulty to target @@ -119,10 +120,11 @@ var pool = module.exports = function pool(options, authorizeFn){ DetectCoinData(function(){ OnBlockchainSynced(function(){ GetFirstJob(function(){ - OutputPoolInfo(); SetupBlockPolling(); - StartStratumServer(); SetupPeer(); + StartStratumServer(function(){ + OutputPoolInfo(); + }); }); }); }); @@ -155,17 +157,28 @@ var pool = module.exports = function pool(options, authorizeFn){ function OutputPoolInfo(){ - if (!process.env.forkId || process.env.forkId === '0') - emitLog(['Pool Server Started...', - 'Running Coin Pool:\t' + options.coin.name + ' [' + options.coin.symbol.toUpperCase() + ']', - 'Network Connected:\t' + (options.testnet ? 'Testnet' : 'Live Blockchain'), - 'Detected Reward Type:\t' + options.coin.reward, - 'Current Block Height:\t' + _this.jobManager.currentJob.rpcData.height, - 'Current Connect Peers:\t' + options.initStats.connections, - 'Network Hash Rate:\t' + (options.initStats.networkHashRate / 1e3).toFixed(6) + ' KH/s', - 'Network Difficulty:\t' + _this.jobManager.currentJob.difficulty - ].join('\n\t\t\t\t\t\t') - ); + if (process.env.forkId && process.env.forkId !== '0'){ + emitLog('Pool Server Started'); + return; + } + var infoLines = ['Stratum Pool Server Started...', + 'Running Coin Pool:\t' + options.coin.name + ' [' + options.coin.symbol.toUpperCase() + ']', + 'Network Connected:\t' + (options.testnet ? 'Testnet' : 'Live Blockchain'), + 'Detected Reward Type:\t' + options.coin.reward, + 'Current Block Height:\t' + _this.jobManager.currentJob.rpcData.height, + 'Current Connect Peers:\t' + options.initStats.connections, + 'Network Hash Rate:\t' + (options.initStats.networkHashRate / 1e3).toFixed(6) + ' KH/s', + 'Network Difficulty:\t' + _this.jobManager.currentJob.difficulty, + 'Listening Port(s):\t' + _this.options.initStats.stratumPorts.join(', ') + ]; + + + + if (typeof options.blockRefreshInterval === "number" && options.blockRefreshInterval > 0) + infoLines.push('Block polling every:\t' + options.blockRefreshInterval + ' ms') + + + emitSpecialLog(infoLines.join('\n\t\t\t\t\t\t')); } @@ -182,7 +195,7 @@ var pool = module.exports = function pool(options, authorizeFn){ else{ if (displayNotSynced) displayNotSynced(); setTimeout(checkSynced, 5000); - generateProgress(smallestHeight); + generateProgress(); } }); @@ -550,11 +563,12 @@ var pool = module.exports = function pool(options, authorizeFn){ - function StartStratumServer(){ + function StartStratumServer(finishedCallback){ _this.stratumServer = new stratum.Server(options.ports, options.connectionTimeout, options.banning, authorizeFn); _this.stratumServer.on('started', function(){ - emitLog('Stratum server started on port(s): ' + Object.keys(options.ports).join(', ')); + options.initStats.stratumPorts = Object.keys(options.ports); + finishedCallback(); _this.emit('started'); }).on('client.connected', function(client){ @@ -622,7 +636,6 @@ var pool = module.exports = function pool(options, authorizeFn){ function SetupBlockPolling(){ - if (typeof options.blockRefreshInterval !== "number" || options.blockRefreshInterval <= 0){ emitLog('Block template polling has been disabled'); return; @@ -633,7 +646,6 @@ var pool = module.exports = function pool(options, authorizeFn){ blockPollingIntervalId = setInterval(function () { GetBlockTemplate(function(error, result){}); }, pollingInterval); - emitLog('Block polling every ' + pollingInterval + ' milliseconds'); }