Prettier log messages on init
This commit is contained in:
parent
b05f7689f3
commit
c8355ea211
48
lib/pool.js
48
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 emitLog = function(text) { _this.emit('log', 'debug' , text); };
|
||||||
var emitWarningLog = function(text) { _this.emit('log', 'warning', text); };
|
var emitWarningLog = function(text) { _this.emit('log', 'warning', text); };
|
||||||
var emitErrorLog = function(text) { _this.emit('log', 'error' , 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
|
//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(){
|
DetectCoinData(function(){
|
||||||
OnBlockchainSynced(function(){
|
OnBlockchainSynced(function(){
|
||||||
GetFirstJob(function(){
|
GetFirstJob(function(){
|
||||||
OutputPoolInfo();
|
|
||||||
SetupBlockPolling();
|
SetupBlockPolling();
|
||||||
StartStratumServer();
|
|
||||||
SetupPeer();
|
SetupPeer();
|
||||||
|
StartStratumServer(function(){
|
||||||
|
OutputPoolInfo();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -155,17 +157,28 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||||||
function OutputPoolInfo(){
|
function OutputPoolInfo(){
|
||||||
|
|
||||||
|
|
||||||
if (!process.env.forkId || process.env.forkId === '0')
|
if (process.env.forkId && process.env.forkId !== '0'){
|
||||||
emitLog(['Pool Server Started...',
|
emitLog('Pool Server Started');
|
||||||
'Running Coin Pool:\t' + options.coin.name + ' [' + options.coin.symbol.toUpperCase() + ']',
|
return;
|
||||||
'Network Connected:\t' + (options.testnet ? 'Testnet' : 'Live Blockchain'),
|
}
|
||||||
'Detected Reward Type:\t' + options.coin.reward,
|
var infoLines = ['Stratum Pool Server Started...',
|
||||||
'Current Block Height:\t' + _this.jobManager.currentJob.rpcData.height,
|
'Running Coin Pool:\t' + options.coin.name + ' [' + options.coin.symbol.toUpperCase() + ']',
|
||||||
'Current Connect Peers:\t' + options.initStats.connections,
|
'Network Connected:\t' + (options.testnet ? 'Testnet' : 'Live Blockchain'),
|
||||||
'Network Hash Rate:\t' + (options.initStats.networkHashRate / 1e3).toFixed(6) + ' KH/s',
|
'Detected Reward Type:\t' + options.coin.reward,
|
||||||
'Network Difficulty:\t' + _this.jobManager.currentJob.difficulty
|
'Current Block Height:\t' + _this.jobManager.currentJob.rpcData.height,
|
||||||
].join('\n\t\t\t\t\t\t')
|
'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{
|
else{
|
||||||
if (displayNotSynced) displayNotSynced();
|
if (displayNotSynced) displayNotSynced();
|
||||||
setTimeout(checkSynced, 5000);
|
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 = new stratum.Server(options.ports, options.connectionTimeout, options.banning, authorizeFn);
|
||||||
|
|
||||||
_this.stratumServer.on('started', function(){
|
_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');
|
_this.emit('started');
|
||||||
|
|
||||||
}).on('client.connected', function(client){
|
}).on('client.connected', function(client){
|
||||||
@ -622,7 +636,6 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||||||
|
|
||||||
|
|
||||||
function SetupBlockPolling(){
|
function SetupBlockPolling(){
|
||||||
|
|
||||||
if (typeof options.blockRefreshInterval !== "number" || options.blockRefreshInterval <= 0){
|
if (typeof options.blockRefreshInterval !== "number" || options.blockRefreshInterval <= 0){
|
||||||
emitLog('Block template polling has been disabled');
|
emitLog('Block template polling has been disabled');
|
||||||
return;
|
return;
|
||||||
@ -633,7 +646,6 @@ var pool = module.exports = function pool(options, authorizeFn){
|
|||||||
blockPollingIntervalId = setInterval(function () {
|
blockPollingIntervalId = setInterval(function () {
|
||||||
GetBlockTemplate(function(error, result){});
|
GetBlockTemplate(function(error, result){});
|
||||||
}, pollingInterval);
|
}, pollingInterval);
|
||||||
emitLog('Block polling every ' + pollingInterval + ' milliseconds');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user