aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerlist.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-08-27 17:37:56 -0400
committerNick Mathewson <nickm@torproject.org>2012-08-27 19:36:12 -0400
commit5c3199cda72fbdcf8f801219a0f9932673801da5 (patch)
treea7a2f1e373e80a6e882e882a0d8b36ce897c7c90 /src/or/routerlist.h
parentef628649c85c9a996b22dfbad494f1757b091d45 (diff)
downloadtor-5c3199cda72fbdcf8f801219a0f9932673801da5.tar
tor-5c3199cda72fbdcf8f801219a0f9932673801da5.tar.gz
In choose-by-bw, scale to better use the range of uint64
The smart part of this is based on an approach and a suggestion by rransom. The unsmart part is my own fault.
Diffstat (limited to 'src/or/routerlist.h')
-rw-r--r--src/or/routerlist.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index 0b9b29751..207261189 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -217,8 +217,17 @@ int hex_digest_nickname_decode(const char *hexdigest,
char *nickname_out);
#ifdef ROUTERLIST_PRIVATE
-int choose_array_element_by_weight(const uint64_t *entries, int n_entries,
- uint64_t *total_out);
+/** Helper type for choosing routers by bandwidth: contains a union of
+ * double and uint64_t. Before we call scale_array_elements_to_u64, it holds
+ * a double; after, it holds a uint64_t. */
+typedef union u64_dbl_t {
+ uint64_t u64;
+ double dbl;
+} u64_dbl_t;
+
+int choose_array_element_by_weight(const u64_dbl_t *entries, int n_entries);
+void scale_array_elements_to_u64(u64_dbl_t *entries, int n_entries,
+ uint64_t *total_out);
#endif
#endif