I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 8690d4d7 authored by jrandom's avatar jrandom Committed by zzz
Browse files

allow explicit overriding any logical constraints on the clock skew (useful...

allow explicit overriding any logical constraints on the clock skew (useful for simulating strange things)
parent d5d9c9b4
No related branches found
No related tags found
No related merge requests found
...@@ -43,20 +43,27 @@ public class Clock implements Timestamper.UpdateListener { ...@@ -43,20 +43,27 @@ public class Clock implements Timestamper.UpdateListener {
/** if the clock skewed changes by less than 1s, ignore the update (so we don't slide all over the place) */ /** if the clock skewed changes by less than 1s, ignore the update (so we don't slide all over the place) */
public final static long MIN_OFFSET_CHANGE = 10 * 1000; public final static long MIN_OFFSET_CHANGE = 10 * 1000;
public void setOffset(long offsetMs) {
setOffset(offsetMs, false);
}
/** /**
* Specify how far away from the "correct" time the computer is - a positive * Specify how far away from the "correct" time the computer is - a positive
* value means that we are slow, while a negative value means we are fast. * value means that we are slow, while a negative value means we are fast.
* *
*/ */
public void setOffset(long offsetMs) { public void setOffset(long offsetMs, boolean force) {
if ((offsetMs > MAX_OFFSET) || (offsetMs < 0 - MAX_OFFSET)) {
getLog().error("Maximum offset shift exceeded [" + offsetMs + "], NOT HONORING IT");
return;
}
long delta = offsetMs - _offset; long delta = offsetMs - _offset;
if ((delta < MIN_OFFSET_CHANGE) && (delta > 0 - MIN_OFFSET_CHANGE)) { if (!force) {
getLog().debug("Not changing offset since it is only " + delta + "ms"); if ((offsetMs > MAX_OFFSET) || (offsetMs < 0 - MAX_OFFSET)) {
return; getLog().error("Maximum offset shift exceeded [" + offsetMs + "], NOT HONORING IT");
return;
}
if ((delta < MIN_OFFSET_CHANGE) && (delta > 0 - MIN_OFFSET_CHANGE)) {
getLog().debug("Not changing offset since it is only " + delta + "ms");
return;
}
} }
if (_alreadyChanged) if (_alreadyChanged)
getLog().log(Log.CRIT, "Updating clock offset to " + offsetMs + "ms from " + _offset + "ms"); getLog().log(Log.CRIT, "Updating clock offset to " + offsetMs + "ms from " + _offset + "ms");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment