From 615c1dbfbf9699e3268e53559369376648cc4fbd Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 27 Mar 2014 09:33:13 -0600 Subject: [PATCH] Better logging.. --- lib/pool.js | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 70dad11..a739ef9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -112,7 +112,6 @@ var pool = module.exports = function pool(options, authorizeFn){ this.start = function(){ - emitLog('Starting pool for ' + options.coin.name + ' [' + options.coin.symbol.toUpperCase() + ']'); SetupJobManager(); SetupVarDiff(); SetupApi(); @@ -141,13 +140,22 @@ var pool = module.exports = function pool(options, authorizeFn){ return; } + var portWarnings = []; + Object.keys(options.ports).forEach(function(port){ var portDiff = options.ports[port].diff; if (portDiff > _this.jobManager.currentJob.difficulty) - emitWarningLog('Pool difficulty of ' + portDiff + ' on port ' + port + - ' was set higher than network difficulty of ' + _this.jobManager.currentJob.difficulty); + portWarnings.push('port ' + port + ' w/ difficulty ' + portDiff); + }); + //Only let the first fork show synced status or the log wil look flooded with it + if (portWarnings.length && !process.env.forkId || process.env.forkId === '0') { + var warnMessage = 'Network difficulty of ' + _this.jobManager.currentJob.difficulty + ' is lower than ' + + portWarnings.join(' and '); + emitWarningLog(warnMessage); + } + finishedCallback(); }); @@ -156,13 +164,12 @@ var pool = module.exports = function pool(options, authorizeFn){ function OutputPoolInfo(){ - + var startMessage = 'Stratum Pool Server Started for ' + options.coin.name + ' [' + options.coin.symbol.toUpperCase() + ']'; if (process.env.forkId && process.env.forkId !== '0'){ - emitLog('Pool Server Started'); + emitLog(startMessage); return; } - var infoLines = ['Stratum Pool Server Started...', - 'Running Coin Pool:\t' + options.coin.name + ' [' + options.coin.symbol.toUpperCase() + ']', + var infoLines = [startMessage, 'Network Connected:\t' + (options.testnet ? 'Testnet' : 'Live Blockchain'), 'Detected Reward Type:\t' + options.coin.reward, 'Current Block Height:\t' + _this.jobManager.currentJob.rpcData.height, @@ -201,7 +208,9 @@ var pool = module.exports = function pool(options, authorizeFn){ }); }; checkSynced(function(){ - emitErrorLog('Daemon is still syncing with network (download blockchain) - server will be started once synced'); + //Only let the first fork show synced status or the log wil look flooded with it + if (!process.env.forkId || process.env.forkId === '0') + emitErrorLog('Daemon is still syncing with network (download blockchain) - server will be started once synced'); }); @@ -217,14 +226,14 @@ var pool = module.exports = function pool(options, authorizeFn){ var peers = results[0].response; var totalBlocks = peers.sort(function(a, b){ - return b.startingheight - a.startingheight; + return a.startingheight - b.startingheight; })[0].startingheight; var percent = (blockCount / totalBlocks * 100).toFixed(2); //Only let the first fork show synced status or the log wil look flooded with it if (!process.env.forkId || process.env.forkId === '0') - emitWarningLog('Downloaded ' + percent + '% of blockchain from network'); + emitWarningLog('Downloaded ' + percent + '% of blockchain from ' + peers.length + ' peers'); }); }); @@ -374,6 +383,10 @@ var pool = module.exports = function pool(options, authorizeFn){ function DetectCoinData(finishedCallback){ + + //TODO: Convert this all into a batch RPC call for better performance + + async.waterfall([