]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Support the ed25519 map in nodelist_assert_ok()
authorNick Mathewson <nickm@torproject.org>
Wed, 9 Aug 2017 18:00:30 +0000 (14:00 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 9 Aug 2017 18:00:30 +0000 (14:00 -0400)
src/or/nodelist.c

index 93d362d8e2c1f31f9447f0a7dbe8a6b473908d65..104915d2938f212e60eff35f7588bca4625c4887 100644 (file)
@@ -725,9 +725,27 @@ nodelist_assert_ok(void)
     tor_assert(node_sl_idx == node->nodelist_idx);
   } SMARTLIST_FOREACH_END(node);
 
+  /* Every node listed with an ed25519 identity should be listed by that
+   * identity.
+   */
+  SMARTLIST_FOREACH_BEGIN(the_nodelist->nodes, node_t *, node) {
+    if (!ed25519_public_key_is_zero(&node->ed25519_id)) {
+      tor_assert(node == node_get_by_ed25519_id(&node->ed25519_id));
+    }
+  } SMARTLIST_FOREACH_END(node);
+
+  node_t **idx;
+  HT_FOREACH(idx, nodelist_ed_map, &the_nodelist->nodes_by_ed_id) {
+    node_t *node = *idx;
+    tor_assert(node == node_get_by_ed25519_id(&node->ed25519_id));
+  }
+
   tor_assert((long)smartlist_len(the_nodelist->nodes) ==
              (long)HT_SIZE(&the_nodelist->nodes_by_id));
 
+  tor_assert((long)smartlist_len(the_nodelist->nodes) >=
+             (long)HT_SIZE(&the_nodelist->nodes_by_ed_id));
+
   digestmap_free(dm, NULL);
 }