[tor-commits] [tor/master] ns: Move dirvote_get_voter_sig_by_alg() to networkstatus.c

nickm at torproject.org nickm at torproject.org
Tue May 1 15:51:58 UTC 2018


commit 098b7fe25bdba20974ebf4ae02ec816316f23383
Author: David Goulet <dgoulet at torproject.org>
Date:   Tue May 1 10:59:10 2018 -0400

    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 at torproject.org>
---
 src/or/dirauth/dirvote.c |  2 +-
 src/or/dirvote_common.c  | 14 --------------
 src/or/dirvote_common.h  |  4 ----
 src/or/networkstatus.c   | 14 ++++++++++++++
 src/or/networkstatus.h   |  4 ++++
 src/or/routerparse.c     |  2 +-
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c
index 36f328d6c..f11b871e5 100644
--- a/src/or/dirauth/dirvote.c
+++ b/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. */
diff --git a/src/or/dirvote_common.c b/src/or/dirvote_common.c
index a28a441d6..354ee0ce7 100644
--- a/src/or/dirvote_common.c
+++ b/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;
-}
-
diff --git a/src/or/dirvote_common.h b/src/or/dirvote_common.h
index 857b8497e..096e5b030 100644
--- a/src/or/dirvote_common.h
+++ b/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 */
 
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 1267d9d6b..99f149020 100644
--- a/src/or/networkstatus.c
+++ b/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
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
index bd7829205..0c325959d 100644
--- a/src/or/networkstatus.h
+++ b/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,
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 3a55c00cc..e4833b441 100644
--- a/src/or/routerparse.c
+++ b/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 "





More information about the tor-commits mailing list