Merge pull request #160 from cubedro/develop
Added send stats as different method
This commit is contained in:
commit
1d29930e51
56
lib/node.js
56
lib/node.js
@ -88,7 +88,6 @@ function Node ()
|
||||
transactions: [],
|
||||
uncles: []
|
||||
},
|
||||
miners: [],
|
||||
uptime: 0
|
||||
};
|
||||
|
||||
@ -476,7 +475,7 @@ Node.prototype.getStats = function(forced)
|
||||
|
||||
self.setUptime();
|
||||
|
||||
self.sendUpdate(forced);
|
||||
self.sendStatsUpdate(forced);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -562,14 +561,6 @@ Node.prototype.changed = function ()
|
||||
return changed;
|
||||
}
|
||||
|
||||
Node.prototype.prepareStats = function ()
|
||||
{
|
||||
return {
|
||||
id: this.id,
|
||||
stats: this.stats
|
||||
};
|
||||
}
|
||||
|
||||
Node.prototype.prepareBlock = function ()
|
||||
{
|
||||
return {
|
||||
@ -578,22 +569,6 @@ Node.prototype.prepareBlock = function ()
|
||||
};
|
||||
}
|
||||
|
||||
Node.prototype.prepareBasic = function ()
|
||||
{
|
||||
return {
|
||||
id: this.id,
|
||||
stats: {
|
||||
active: this.stats.active,
|
||||
mining: this.stats.mining,
|
||||
hashrate: this.stats.hashrate,
|
||||
peers: this.stats.peers,
|
||||
gasPrice: this.stats.gasPrice,
|
||||
miners: this.stats.miners,
|
||||
uptime: this.stats.uptime
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Node.prototype.preparePending = function ()
|
||||
{
|
||||
return {
|
||||
@ -604,12 +579,19 @@ Node.prototype.preparePending = function ()
|
||||
};
|
||||
}
|
||||
|
||||
Node.prototype.sendUpdate = function (force)
|
||||
Node.prototype.prepareStats = function ()
|
||||
{
|
||||
if( this.changed() || force ) {
|
||||
console.info("wsc", "Sending", chalk.reset.blue((force ? "forced" : "changed")), chalk.bold.white("update"));
|
||||
this.emit('update', this.prepareStats());
|
||||
}
|
||||
return {
|
||||
id: this.id,
|
||||
stats: {
|
||||
active: this.stats.active,
|
||||
mining: this.stats.mining,
|
||||
hashrate: this.stats.hashrate,
|
||||
peers: this.stats.peers,
|
||||
gasPrice: this.stats.gasPrice,
|
||||
uptime: this.stats.uptime
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Node.prototype.sendBlockUpdate = function()
|
||||
@ -620,9 +602,15 @@ Node.prototype.sendBlockUpdate = function()
|
||||
|
||||
Node.prototype.sendPendingUpdate = function()
|
||||
{
|
||||
if( this.changed() ) {
|
||||
console.info("wsc", "Sending pending update");
|
||||
this.emit('pending', this.preparePending());
|
||||
console.info("wsc", "Sending pending update");
|
||||
this.emit('pending', this.preparePending());
|
||||
}
|
||||
|
||||
Node.prototype.sendStatsUpdate = function (force)
|
||||
{
|
||||
if( this.changed() || force ) {
|
||||
console.info("wsc", "Sending", chalk.reset.blue((force ? "forced" : "changed")), chalk.bold.white("update"));
|
||||
this.emit('stats', this.prepareStats());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user