Commit 0f4c48ee authored by Hiro's avatar Hiro 🏄
Browse files

Move logic when lastRestarted is set

parent 8ea27f30
Pipeline #36787 failed with stage
in 1 minute and 24 seconds
......@@ -183,6 +183,26 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
Math.min(bandwidthBurst, observedBandwidth));
detailsStatus.setDescPublished(descriptor.getPublishedMillis());
detailsStatus.setLastRestarted(calculateLastRestartedMillis(descriptor));
/**
* This is a bit of a hack. We read the uptime document to see if
* the relay/bridge had been on the network longer than what we thought.
* We should check instead why the firstSeenMillis attribute get set to
* 0 but it might be digging to deep into the onionoo cave.
**/
if (detailsStatus.getFirstSeenMillis()
> detailsStatus.getLastRestarted()) {
UptimeStatus uptimeStatus = this.documentStore.retrieve(
UptimeStatus.class, true, fingerprint);
if (uptimeStatus != null) {
if (detailsStatus.isRelay()) {
detailsStatus.setFirstSeenMillis(
uptimeStatus.getRelayHistory().first().getStartMillis()
);
}
}
}
detailsStatus.setBandwidthRate(bandwidthRate);
detailsStatus.setBandwidthBurst(bandwidthBurst);
detailsStatus.setObservedBandwidth(observedBandwidth);
......@@ -348,6 +368,27 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
descriptor.getBandwidthObserved()));
detailsStatus.setDescPublished(descriptor.getPublishedMillis());
detailsStatus.setLastRestarted(calculateLastRestartedMillis(descriptor));
/**
* This is a bit of a hack. We read the uptime document to see if
* the relay/bridge had been on the network longer than what we thought.
* We should check instead why the firstSeenMillis attribute get set to
* 0 but it might be digging to deep into the onionoo cave.
**/
if (detailsStatus.getFirstSeenMillis()
> detailsStatus.getLastRestarted()) {
UptimeStatus uptimeStatus = this.documentStore.retrieve(
UptimeStatus.class, true, fingerprint);
if (uptimeStatus != null) {
if (!detailsStatus.isRelay()) {
detailsStatus.setFirstSeenMillis(
uptimeStatus.getBridgeHistory().first().getStartMillis()
);
}
}
}
detailsStatus.setAdvertisedBandwidth(advertisedBandwidth);
long overloadGeneralTimestamp = descriptor.getOverloadGeneralTimestamp();
detailsStatus.setOverloadGeneralTimestamp(overloadGeneralTimestamp);
......@@ -578,29 +619,6 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
nodeStatus.getFirstSeenMillis());
}
/**
* This is a bit of a hack. We read the uptime document to see if
* the relay/bridge had been on the network longer than what we thought.
* We should check instead why the firstSeenMillis attribute get set to
* 0 but it might be digging to deep into the onionoo cave.
**/
if (nodeStatus.getFirstSeenMillis()
> updatedNodeStatus.getLastRestarted()) {
UptimeStatus uptimeStatus = this.documentStore.retrieve(
UptimeStatus.class, true, fingerprint);
if (uptimeStatus != null) {
if (updatedNodeStatus.isRelay()) {
updatedNodeStatus.setFirstSeenMillis(
uptimeStatus.getRelayHistory().first().getStartMillis()
);
} else {
updatedNodeStatus.setFirstSeenMillis(
uptimeStatus.getBridgeHistory().first().getStartMillis()
);
}
}
}
updatedNodeStatus.setDeclaredFamily(
nodeStatus.getDeclaredFamily());
updatedNodeStatus.setEffectiveFamily(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment