[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [metrics-db/master] Try harder to fix consensus-health.html.
commit 4ee40afd266722e4b0bd01a1fbf65a745979da4d
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue Jan 18 14:51:41 2011 +0100
Try harder to fix consensus-health.html.
---
.../ernie/db/ConsensusHealthChecker.java | 21 ++++++++++++-------
1 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/org/torproject/ernie/db/ConsensusHealthChecker.java b/src/org/torproject/ernie/db/ConsensusHealthChecker.java
index dc82e5d..5af1523 100644
--- a/src/org/torproject/ernie/db/ConsensusHealthChecker.java
+++ b/src/org/torproject/ernie/db/ConsensusHealthChecker.java
@@ -35,14 +35,19 @@ public class ConsensusHealthChecker {
}
public void processConsensus(String validAfterTime, byte[] data) {
- if (this.mostRecentValidAfterTime != null &&
- this.mostRecentValidAfterTime.compareTo(validAfterTime) > 0) {
- /* We already have a more recent consensus. */
- return;
- }
- /* The votes we know are older than this consensus. Discard them. */
- if (this.mostRecentValidAfterTime.compareTo(validAfterTime) < 0) {
- this.mostRecentVotes.clear();
+ /* Do we already know a consensus and/or vote(s)? */
+ if (this.mostRecentValidAfterTime != null) {
+ int compareKnownToNew =
+ this.mostRecentValidAfterTime.compareTo(validAfterTime);
+ if (compareKnownToNew > 0) {
+ /* The consensus or vote(s) we know are more recent than this
+ * consensus. No need to store it. */
+ return;
+ } else if (compareKnownToNew < 0) {
+ /* This consensus is newer than the known consensus or vote(s).
+ * Discard all known votes and overwrite the consensus below. */
+ this.mostRecentVotes.clear();
+ }
}
/* Store this consensus. */
this.mostRecentValidAfterTime = validAfterTime;