Browse Source

ns: Move dirvote_get_voter_sig_by_alg() to networkstatus.c

It makes more sense to be in networkstatus.c so move it there and rename it
with the "networkstatus_" prefix.

Part of #25988

Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet 6 years ago
parent
commit
098b7fe25b

+ 1 - 1
src/or/dirauth/dirvote.c

@@ -2516,7 +2516,7 @@ networkstatus_add_detached_signatures(networkstatus_t *target,
       continue;
     }
 
-    old_sig = dirvote_get_voter_sig_by_alg(target_voter, sig->alg);
+    old_sig = networkstatus_get_voter_sig_by_alg(target_voter, sig->alg);
 
     /* If the target already has a good signature from this voter, then skip
      * this one. */

+ 0 - 14
src/or/dirvote_common.c

@@ -179,17 +179,3 @@ dirvote_recalculate_timing(const or_options_t *options, time_t now)
   voting_schedule_free(new_voting_schedule);
 }
 
-/** Return the signature made by <b>voter</b> using the algorithm
- * <b>alg</b>, or NULL if none is found. */
-document_signature_t *
-dirvote_get_voter_sig_by_alg(const networkstatus_voter_info_t *voter,
-                             digest_algorithm_t alg)
-{
-  if (!voter->sigs)
-    return NULL;
-  SMARTLIST_FOREACH(voter->sigs, document_signature_t *, sig,
-                    if (sig->alg == alg)
-                    return sig);
-  return NULL;
-}
-

+ 0 - 4
src/or/dirvote_common.h

@@ -58,9 +58,5 @@ time_t dirvote_get_start_of_next_interval(time_t now,
                                           int offset);
 time_t dirvote_get_next_valid_after_time(void);
 
-document_signature_t *dirvote_get_voter_sig_by_alg(
-                           const networkstatus_voter_info_t *voter,
-                           digest_algorithm_t alg);
-
 #endif /* TOR_DIRVOTE_COMMON_H */
 

+ 14 - 0
src/or/networkstatus.c

@@ -390,6 +390,20 @@ networkstatus_get_voter_by_id(networkstatus_t *vote,
   return NULL;
 }
 
+/** Return the signature made by <b>voter</b> using the algorithm
+ * <b>alg</b>, or NULL if none is found. */
+document_signature_t *
+networkstatus_get_voter_sig_by_alg(const networkstatus_voter_info_t *voter,
+                                   digest_algorithm_t alg)
+{
+  if (!voter->sigs)
+    return NULL;
+  SMARTLIST_FOREACH(voter->sigs, document_signature_t *, sig,
+                    if (sig->alg == alg)
+                    return sig);
+  return NULL;
+}
+
 /** Check whether the signature <b>sig</b> is correctly signed with the
  * signing key in <b>cert</b>.  Return -1 if <b>cert</b> doesn't match the
  * signing key; otherwise set the good_signature or bad_signature flag on

+ 4 - 0
src/or/networkstatus.h

@@ -30,6 +30,10 @@ void ns_detached_signatures_free_(ns_detached_signatures_t *s);
 networkstatus_voter_info_t *networkstatus_get_voter_by_id(
                                        networkstatus_t *vote,
                                        const char *identity);
+document_signature_t *networkstatus_get_voter_sig_by_alg(
+                                    const networkstatus_voter_info_t *voter,
+                                    digest_algorithm_t alg);
+
 int networkstatus_check_consensus_signature(networkstatus_t *consensus,
                                             int warn);
 int networkstatus_check_document_signature(const networkstatus_t *consensus,

+ 1 - 1
src/or/routerparse.c

@@ -3912,7 +3912,7 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
       }
     }
 
-    if (dirvote_get_voter_sig_by_alg(v, sig->alg)) {
+    if (networkstatus_get_voter_sig_by_alg(v, sig->alg)) {
       /* We already parsed a vote with this algorithm from this voter. Use the
          first one. */
       log_fn(LOG_PROTOCOL_WARN, LD_DIR, "We received a networkstatus "