Added testNtpOffset settings field (+ minor settings docs changes)

This commit is contained in:
catbref 2019-09-23 16:44:47 +01:00
parent 0dd5b1e65a
commit 4b5ed79c5a
2 changed files with 10 additions and 3 deletions

View File

@ -68,11 +68,12 @@ public class Settings {
private int maxUnconfirmedPerAccount = 100; private int maxUnconfirmedPerAccount = 100;
/** Max milliseconds into future for accepting new, unconfirmed transactions */ /** Max milliseconds into future for accepting new, unconfirmed transactions */
private int maxTransactionTimestampFuture = 24 * 60 * 60 * 1000; // milliseconds private int maxTransactionTimestampFuture = 24 * 60 * 60 * 1000; // milliseconds
// auto-update /** Whether we check, fetch and install auto-updates */
private boolean autoUpdateEnabled = true; private boolean autoUpdateEnabled = true;
// Peer-to-peer related // Peer-to-peer related
private boolean isTestNet = false; private boolean isTestNet = false;
/** Port number for inbound peer-to-peer connections. */
private Integer listenPort; private Integer listenPort;
/** Minimum number of peers to allow block generation / synchronization. */ /** Minimum number of peers to allow block generation / synchronization. */
private int minBlockchainPeers = 3; private int minBlockchainPeers = 3;
@ -97,7 +98,7 @@ public class Settings {
"https://raw.githubusercontent.com@151.101.16.133/catbref/qora-core/%s/qora-core.jar" "https://raw.githubusercontent.com@151.101.16.133/catbref/qora-core/%s/qora-core.jar"
}; };
// NTP sources /** Array of NTP server hostnames. */
private String[] ntpServers = new String[] { private String[] ntpServers = new String[] {
"pool.ntp.org", "pool.ntp.org",
"0.pool.ntp.org", "0.pool.ntp.org",
@ -110,6 +111,8 @@ public class Settings {
"2.cn.pool.ntp.org", "2.cn.pool.ntp.org",
"3.cn.pool.ntp.org" "3.cn.pool.ntp.org"
}; };
/** Additional offset added to values returned by NTP.getTime() */
private long testNtpOffset = 0;
// Constructors // Constructors
@ -328,4 +331,8 @@ public class Settings {
return this.ntpServers; return this.ntpServers;
} }
public long getTestNtpOffset() {
return this.testNtpOffset;
}
} }

View File

@ -151,7 +151,7 @@ public class NTP implements Runnable {
if (NTP.offset == null) if (NTP.offset == null)
return null; return null;
return System.currentTimeMillis() + NTP.offset; return System.currentTimeMillis() + NTP.offset + Settings.getInstance().getTestNtpOffset();
} }
public void run() { public void run() {