|
@@ -113,6 +113,11 @@ typedef struct nodelist_t {
|
|
|
|
|
|
|
|
|
address_set_t *node_addrs;
|
|
|
+
|
|
|
+
|
|
|
+ * nodelist. We use this to detect outdated nodelists that need to be
|
|
|
+ * rebuilt using a newer consensus. */
|
|
|
+ time_t live_consensus_valid_after;
|
|
|
} nodelist_t;
|
|
|
|
|
|
static inline unsigned int
|
|
@@ -630,6 +635,12 @@ nodelist_set_consensus(networkstatus_t *ns)
|
|
|
}
|
|
|
} SMARTLIST_FOREACH_END(node);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * the nodelist. */
|
|
|
+ if (networkstatus_is_live(ns, approx_time())) {
|
|
|
+ the_nodelist->live_consensus_valid_after = ns->valid_after;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -854,6 +865,25 @@ nodelist_assert_ok(void)
|
|
|
digestmap_free(dm, NULL);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * If that's not the case, make it so. */
|
|
|
+void
|
|
|
+nodelist_ensure_freshness(networkstatus_t *ns)
|
|
|
+{
|
|
|
+ tor_assert(ns);
|
|
|
+
|
|
|
+
|
|
|
+ if (!the_nodelist) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (the_nodelist->live_consensus_valid_after != ns->valid_after) {
|
|
|
+ log_info(LD_GENERAL, "Nodelist was not fresh: rebuilding. (%d / %d)",
|
|
|
+ (int) the_nodelist->live_consensus_valid_after,
|
|
|
+ (int) ns->valid_after);
|
|
|
+ nodelist_set_consensus(ns);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
* MUST NOT modify the list. (You can set and clear flags in the nodes if
|
|
|
* you must, but you must not add or remove nodes.) */
|