[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [onionoo/master] Don't reset probabilities when not parsing a consensus.



commit c504cf5d62b8425a47dea74d45d02acd3f8325aa
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Feb 17 10:36:49 2015 +0100

    Don't reset probabilities when not parsing a consensus.
    
    Since the recent refactoring we make probabilities persistent in details
    status files.  Now, if we don't parse a new consensus, we shouldn't reset
    probabilities, because details documents can still use probabilities from
    the last execution, which are contained in details statuses.
    
    This fixes the bug where all relays' guard/middle/exit weights are set to
    0.0 whenever we're not parsing a new consensus.  Fixes #12656.
---
 .../onionoo/updater/NodeDetailsStatusUpdater.java  |   31 +++++++++++++-------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
index 33a8302..be2bd9a 100644
--- a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
+++ b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
@@ -541,10 +541,11 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
         wed = ((double) this.lastBandwidthWeights.get("Wed")) / 10000.0;
       }
     } else {
-      log.error("Could not determine most recent Wxx parameter "
+      log.debug("Not calculating new path selection probabilities, "
+          + "because we could not determine most recent Wxx parameter "
           + "values, probably because we didn't parse a consensus in "
-          + "this execution.  All relays' guard/middle/exit weights are "
-          + "going to be 0.0.");
+          + "this execution.");
+      return;
     }
     SortedMap<String, Double>
         consensusWeights = new TreeMap<String, Double>(),
@@ -709,14 +710,22 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
         nodeStatus.setASNumber(lookupResult.getAsNumber());
       }
 
-      detailsStatus.setConsensusWeightFraction(
-          this.consensusWeightFractions.get(fingerprint));
-      detailsStatus.setGuardProbability(
-          this.guardProbabilities.get(fingerprint));
-      detailsStatus.setMiddleProbability(
-          this.middleProbabilities.get(fingerprint));
-      detailsStatus.setExitProbability(
-          this.exitProbabilities.get(fingerprint));
+      if (this.consensusWeightFractions.containsKey(fingerprint)) {
+        detailsStatus.setConsensusWeightFraction(
+            this.consensusWeightFractions.get(fingerprint));
+      }
+      if (this.guardProbabilities.containsKey(fingerprint)) {
+        detailsStatus.setGuardProbability(
+            this.guardProbabilities.get(fingerprint));
+      }
+      if (this.middleProbabilities.containsKey(fingerprint)) {
+        detailsStatus.setMiddleProbability(
+            this.middleProbabilities.get(fingerprint));
+      }
+      if (this.exitProbabilities.containsKey(fingerprint)) {
+        detailsStatus.setExitProbability(
+            this.exitProbabilities.get(fingerprint));
+      }
 
       if (this.rdnsLookupResults.containsKey(fingerprint)) {
         String hostName = this.rdnsLookupResults.get(fingerprint);

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits