updated ping-pong
This commit is contained in:
parent
ba3d418c9b
commit
fd3abea39c
11
lib/node.js
11
lib/node.js
@ -105,7 +105,6 @@ function Node ()
|
||||
this._socket = false;
|
||||
|
||||
this._latestQueue = null;
|
||||
this._chainDebouncer = 0;
|
||||
this.pendingFilter = false;
|
||||
this.chainFilter = false;
|
||||
this.updateInterval = false;
|
||||
@ -114,7 +113,9 @@ function Node ()
|
||||
|
||||
this._lastChainLog = 0;
|
||||
this._lastPendingLog = 0;
|
||||
this._chainDebouncer = 0;
|
||||
this._connection_attempts = 0
|
||||
this._timeOffset = null;
|
||||
|
||||
this.startWeb3Connection();
|
||||
|
||||
@ -216,7 +217,8 @@ Node.prototype.setupSockets = function()
|
||||
})
|
||||
.on('node-pong', function(data)
|
||||
{
|
||||
var latency = Math.ceil( (_.now() - self._latency) / 2 );
|
||||
var now = _.now();
|
||||
var latency = Math.ceil( (now - data.clientTime) / 2 );
|
||||
|
||||
socket.emit('latency', {
|
||||
id: self.id,
|
||||
@ -629,7 +631,10 @@ Node.prototype.sendStatsUpdate = function (force)
|
||||
Node.prototype.ping = function()
|
||||
{
|
||||
this._latency = _.now();
|
||||
socket.emit('node-ping', { id: this.id });
|
||||
socket.emit('node-ping', {
|
||||
id: this.id,
|
||||
clientTime: _.now()
|
||||
});
|
||||
};
|
||||
|
||||
Node.prototype.setWatches = function()
|
||||
|
Loading…
Reference in New Issue
Block a user