timedata: minor.
This commit is contained in:
parent
bd56c75d0d
commit
a11a1ab4ad
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const util = require('../utils/util');
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
|
const util = require('../utils/util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object which handles "adjusted time". This may not
|
* An object which handles "adjusted time". This may not
|
||||||
@ -37,7 +37,7 @@ function TimeData(limit) {
|
|||||||
this.known = new Map();
|
this.known = new Map();
|
||||||
this.limit = limit;
|
this.limit = limit;
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
this._checked = false;
|
this.checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
util.inherits(TimeData, EventEmitter);
|
util.inherits(TimeData, EventEmitter);
|
||||||
@ -70,7 +70,7 @@ TimeData.prototype.add = function add(id, time) {
|
|||||||
this.offset = median;
|
this.offset = median;
|
||||||
} else {
|
} else {
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
if (!this._checked) {
|
if (!this.checked) {
|
||||||
let match = false;
|
let match = false;
|
||||||
for (let offset of this.samples) {
|
for (let offset of this.samples) {
|
||||||
if (offset !== 0 && Math.abs(offset) < 5 * 60) {
|
if (offset !== 0 && Math.abs(offset) < 5 * 60) {
|
||||||
@ -79,7 +79,7 @@ TimeData.prototype.add = function add(id, time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!match) {
|
if (!match) {
|
||||||
this._checked = true;
|
this.checked = true;
|
||||||
this.emit('mismatch');
|
this.emit('mismatch');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user