Browse Source

More documentation for proposal 227 work

Nick Mathewson 10 years ago
parent
commit
ddfdeb5659
3 changed files with 20 additions and 4 deletions
  1. 6 0
      doc/tor.1.txt
  2. 4 1
      src/common/container.c
  3. 10 3
      src/or/dirvote.c

+ 6 - 0
doc/tor.1.txt

@@ -1881,6 +1881,12 @@ on the public Tor network.
     multiple times: the values from multiple lines are spliced together. When
     this is set then **VersioningAuthoritativeDirectory** should be set too.
 
+[[RecommendedPackageVersions]] **RecommendedPackageVersions** __PACKAGENAME__ __VERSION__ __URL__ __DIGESTTYPE__**=**__DIGEST__ ::
+    Adds "package" line to the directory authority's vote.  This information
+    is used to vote on the correct URL and digest for the released versions
+    of different Tor-related packages, so that the consensus can certify
+    them.  This line may appear any number of times.
+
 [[RecommendedClientVersions]] **RecommendedClientVersions** __STRING__::
     STRING is a comma-separated list of Tor versions currently believed to be
     safe for clients to use. This information is included in version 2

+ 4 - 1
src/common/container.c

@@ -735,7 +735,10 @@ smartlist_get_most_frequent_string(smartlist_t *sl)
   return smartlist_get_most_frequent(sl, compare_string_ptrs_);
 }
 
-/** Return the most frequent string in the sorted list <b>sl</b> */
+/** Return the most frequent string in the sorted list <b>sl</b>.
+ * If <b>count_out</b> is provided, set <b>count_out</b> to the
+ * number of times that string appears.
+ */
 char *
 smartlist_get_most_frequent_string_(smartlist_t *sl, int *count_out)
 {

+ 10 - 3
src/or/dirvote.c

@@ -1886,13 +1886,18 @@ networkstatus_compute_consensus(smartlist_t *votes,
   return result;
 }
 
-/** DOCDOC */
+/** Given a list of networkstatus_t for each vote, return a newly allocated
+ * string containing the "package" lines for the vote. */
 STATIC char *
 compute_consensus_package_lines(smartlist_t *votes)
 {
   const int n_votes = smartlist_len(votes);
+
+  /* This will be a map from "packagename version" strings to arrays
+   * of const char *, with the i'th member of the array corresponding to the
+   * package line from the i'th vote.
+   */
   strmap_t *package_status = strmap_new();
-  smartlist_t *result_list = smartlist_new();
 
   SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
     if (! v->package_lines)
@@ -1901,6 +1906,7 @@ compute_consensus_package_lines(smartlist_t *votes)
       if (! validate_recommended_package_line(line))
         continue;
 
+      /* Skip 'cp' to the second space in the line. */
       const char *cp = strchr(line, ' ');
       if (!cp) continue;
       ++cp;
@@ -1919,7 +1925,8 @@ compute_consensus_package_lines(smartlist_t *votes)
     } SMARTLIST_FOREACH_END(line);
   } SMARTLIST_FOREACH_END(v);
 
-  smartlist_t *entries = smartlist_new();
+  smartlist_t *entries = smartlist_new(); /* temporary */
+  smartlist_t *result_list = smartlist_new(); /* output */
   STRMAP_FOREACH(package_status, key, const char **, values) {
     int i, count=-1;
     for (i = 0; i < n_votes; ++i) {