forked from Qortal/qortal
Relax max clock offsets for block gen and peer connections.
It seems unachievable for nodes to keep their clocks accurate to within 500ms. It is unclear whether this is due to Windows' implementation of client NTP or because of terrible network conditions in China. So increasing max NTP offset to allow block generation from 500ms to 30s. Correspondingly increasing max peer timestamp delta from 5s to 30s. The block consensus algorithm will need to change in the near future to address clock issues.
This commit is contained in:
parent
63036f3592
commit
05e491f65b
@ -20,6 +20,7 @@ public class ConnectedPeer {
|
||||
public Handshake handshakeStatus;
|
||||
public Long lastPing;
|
||||
public Long connectedWhen;
|
||||
public Long peersConnectedWhen;
|
||||
|
||||
public String address;
|
||||
public String version;
|
||||
@ -39,7 +40,8 @@ public class ConnectedPeer {
|
||||
this.lastPing = peer.getLastPing();
|
||||
|
||||
PeerData peerData = peer.getPeerData();
|
||||
this.connectedWhen = peerData.getLastConnected();
|
||||
this.connectedWhen = peer.getConnectionTimestamp();
|
||||
this.peersConnectedWhen = peer.getPeersConnectionTimestamp();
|
||||
|
||||
this.address = peerData.getAddress().toString();
|
||||
if (peer.getVersionMessage() != null) {
|
||||
|
@ -92,7 +92,7 @@ public class Controller extends Thread {
|
||||
private static final long ARBITRARY_REQUEST_TIMEOUT = 5 * 1000; // ms
|
||||
private static final long REPOSITORY_BACKUP_PERIOD = 123 * 60 * 1000; // ms
|
||||
private static final long NTP_CHECK_PERIOD = 10 * 60 * 1000; // ms
|
||||
private static final long MAX_NTP_OFFSET = 500; // ms
|
||||
private static final long MAX_NTP_OFFSET = 30 * 1000; // ms
|
||||
|
||||
private static volatile boolean isStopping = false;
|
||||
private static BlockGenerator blockGenerator = null;
|
||||
|
@ -106,6 +106,9 @@ public enum Handshake {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Save peer's value for connectionTimestamp
|
||||
peer.setPeersConnectionTimestamp(proofMessage.getTimestamp());
|
||||
|
||||
// If we connected outbound to peer, then this is a faked confirmation response, so we're good
|
||||
if (peer.isOutbound())
|
||||
return COMPLETED;
|
||||
@ -176,7 +179,7 @@ public enum Handshake {
|
||||
private static final Logger LOGGER = LogManager.getLogger(Handshake.class);
|
||||
|
||||
/** Maximum allowed difference between peer's reported timestamp and when they connected, in milliseconds. */
|
||||
private static final long MAX_TIMESTAMP_DELTA = 5000; // ms
|
||||
private static final long MAX_TIMESTAMP_DELTA = 30 * 1000; // ms
|
||||
|
||||
public final MessageType expectedMessageType;
|
||||
|
||||
|
@ -80,6 +80,9 @@ public class Peer {
|
||||
/** Timestamp of when socket was accepted, or connected. */
|
||||
private Long connectionTimestamp = null;
|
||||
|
||||
/** Peer's value of connectionTimestamp. */
|
||||
private Long peersConnectionTimestamp = null;
|
||||
|
||||
/** Version info as reported by peer. */
|
||||
private VersionMessage versionMessage = null;
|
||||
|
||||
@ -169,6 +172,14 @@ public class Peer {
|
||||
return this.connectionTimestamp;
|
||||
}
|
||||
|
||||
public Long getPeersConnectionTimestamp() {
|
||||
return this.peersConnectionTimestamp;
|
||||
}
|
||||
|
||||
/* package */ void setPeersConnectionTimestamp(Long peersConnectionTimestamp) {
|
||||
this.peersConnectionTimestamp = peersConnectionTimestamp;
|
||||
}
|
||||
|
||||
public Long getLastPing() {
|
||||
return this.lastPing;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user