Browse Source

Report as 100% synced if the latest block is within the last 30 mins

This should hopefully reduce confusion due to APIs reporting 99% synced even though up to date. The systray should never show this since it already treats blocks in the last 30 mins as synced.
pull/75/head
CalDescent 3 years ago
parent
commit
9013d11d24
  1. 2
      src/main/java/org/qortal/api/model/NodeStatus.java
  2. 6
      src/main/java/org/qortal/controller/Synchronizer.java

2
src/main/java/org/qortal/api/model/NodeStatus.java

@ -24,7 +24,7 @@ public class NodeStatus {
this.isMintingPossible = Controller.getInstance().isMintingPossible(); this.isMintingPossible = Controller.getInstance().isMintingPossible();
this.syncPercent = Synchronizer.getInstance().getSyncPercent(); this.syncPercent = Synchronizer.getInstance().getSyncPercent();
this.isSynchronizing = this.syncPercent != null; this.isSynchronizing = Synchronizer.getInstance().isSynchronizing();
this.numberOfConnections = Network.getInstance().getImmutableHandshakedPeers().size(); this.numberOfConnections = Network.getInstance().getImmutableHandshakedPeers().size();

6
src/main/java/org/qortal/controller/Synchronizer.java

@ -173,6 +173,12 @@ public class Synchronizer extends Thread {
public Integer getSyncPercent() { public Integer getSyncPercent() {
synchronized (this.syncLock) { synchronized (this.syncLock) {
// Report as 100% synced if the latest block is within the last 30 mins
final Long minLatestBlockTimestamp = NTP.getTime() - (30 * 60 * 1000L);
if (Controller.getInstance().isUpToDate(minLatestBlockTimestamp)) {
return 100;
}
return this.isSynchronizing ? this.syncPercent : null; return this.isSynchronizing ? this.syncPercent : null;
} }
} }

Loading…
Cancel
Save