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

[tor-commits] [metrics-lib/master] Distinguish between not recommending anything and recommending nothing.



commit d17812139aa1642883b932a0716b39e94141d180
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Dec 13 12:47:24 2011 +0100

    Distinguish between not recommending anything and recommending nothing.
---
 .../descriptor/RelayNetworkStatusConsensus.java    |    6 ++++--
 .../descriptor/RelayNetworkStatusVote.java         |    6 ++++--
 .../impl/RelayNetworkStatusConsensusImpl.java      |   16 ++++++++--------
 .../impl/RelayNetworkStatusVoteImpl.java           |   16 ++++++++--------
 4 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java b/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java
index 452a0ba..17beeb5 100755
--- a/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java
+++ b/src/org/torproject/descriptor/RelayNetworkStatusConsensus.java
@@ -27,10 +27,12 @@ public interface RelayNetworkStatusConsensus extends Descriptor {
   /* Return a list of the voting-delay times in seconds. */
   public List<Long> getVotingDelay();
 
-  /* Return cecommended server versions. */
+  /* Return recommended server versions or null if the consensus doesn't
+   * contain recommended server versions. */
   public SortedSet<String> getRecommendedServerVersions();
 
-  /* Return recommended client versions. */
+  /* Return recommended client versions or null if the consensus doesn't
+   * contain recommended client versions. */
   public SortedSet<String> getRecommendedClientVersions();
 
   /* Return known relay flags. */
diff --git a/src/org/torproject/descriptor/RelayNetworkStatusVote.java b/src/org/torproject/descriptor/RelayNetworkStatusVote.java
index 7d85a0c..f591c10 100755
--- a/src/org/torproject/descriptor/RelayNetworkStatusVote.java
+++ b/src/org/torproject/descriptor/RelayNetworkStatusVote.java
@@ -30,10 +30,12 @@ public interface RelayNetworkStatusVote extends Descriptor {
   /* Return a list of the voting-delay times in seconds. */
   public List<Long> getVotingDelay();
 
-  /* Return cecommended server versions. */
+  /* Return recommended server versions or null if the authority doesn't
+   * recommend server versions. */
   public SortedSet<String> getRecommendedServerVersions();
 
-  /* Return recommended client versions. */
+  /* Return recommended client versions or null if the authority doesn't
+   * recommend server versions. */
   public SortedSet<String> getRecommendedClientVersions();
 
   /* Return known relay flags. */
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
index 3d2b0a2..7cbe94c 100755
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
@@ -94,10 +94,10 @@ public class RelayNetworkStatusConsensusImpl
             this.votingDelay.add(Long.parseLong(votingDelayString));
           }
         } else if (line.startsWith("client-versions ")) {
-          this.recommendedClientVersions.addAll(
+          this.recommendedClientVersions = new TreeSet<String>(
               Arrays.asList(line.split(" ")[1].split(",")));
         } else if (line.startsWith("server-versions ")) {
-          this.recommendedServerVersions.addAll(
+          this.recommendedServerVersions = new TreeSet<String>(
               Arrays.asList(line.split(" ")[1].split(",")));
         } else if (line.startsWith("known-flags ")) {
           for (String flag : line.substring("known-flags ".length()).
@@ -257,16 +257,16 @@ public class RelayNetworkStatusConsensusImpl
     return new ArrayList<Long>(this.votingDelay);
   }
 
-  private SortedSet<String> recommendedClientVersions =
-      new TreeSet<String>();
+  private SortedSet<String> recommendedClientVersions;
   public SortedSet<String> getRecommendedClientVersions() {
-    return new TreeSet<String>(this.recommendedClientVersions);
+    return this.recommendedClientVersions == null ? null :
+        new TreeSet<String>(this.recommendedClientVersions);
   }
 
-  private SortedSet<String> recommendedServerVersions =
-      new TreeSet<String>();
+  private SortedSet<String> recommendedServerVersions;
   public SortedSet<String> getRecommendedServerVersions() {
-    return new TreeSet<String>(this.recommendedServerVersions);
+    return this.recommendedServerVersions == null ? null :
+        new TreeSet<String>(this.recommendedServerVersions);
   }
 
   private SortedSet<String> knownFlags = new TreeSet<String>();
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
index fa5b4d5..bf2668b 100755
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
@@ -100,10 +100,10 @@ public class RelayNetworkStatusVoteImpl
             this.votingDelay.add(Long.parseLong(votingDelayString));
           }
         } else if (line.startsWith("client-versions ")) {
-          this.recommendedClientVersions.addAll(
+          this.recommendedClientVersions = new TreeSet<String>(
               Arrays.asList(line.split(" ")[1].split(",")));
         } else if (line.startsWith("server-versions ")) {
-          this.recommendedServerVersions.addAll(
+          this.recommendedServerVersions = new TreeSet<String>(
               Arrays.asList(line.split(" ")[1].split(",")));
         } else if (line.startsWith("known-flags ")) {
           for (String flag : line.substring("known-flags ".length()).
@@ -233,16 +233,16 @@ public class RelayNetworkStatusVoteImpl
     return new ArrayList<Long>(this.votingDelay);
   }
 
-  private SortedSet<String> recommendedClientVersions =
-      new TreeSet<String>();
+  private SortedSet<String> recommendedClientVersions;
   public SortedSet<String> getRecommendedClientVersions() {
-    return new TreeSet<String>(this.recommendedClientVersions);
+    return this.recommendedClientVersions == null ? null :
+        new TreeSet<String>(this.recommendedClientVersions);
   }
 
-  private SortedSet<String> recommendedServerVersions =
-      new TreeSet<String>();
+  private SortedSet<String> recommendedServerVersions;
   public SortedSet<String> getRecommendedServerVersions() {
-    return new TreeSet<String>(this.recommendedServerVersions);
+    return this.recommendedServerVersions == null ? null :
+        new TreeSet<String>(this.recommendedServerVersions);
   }
 
   private SortedSet<String> knownFlags = new TreeSet<String>();

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