diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-09-28 13:29:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-10-01 18:14:26 -0400 |
commit | fe309e7ad633bee36e175e600f0b9a0ac18cf981 (patch) | |
tree | 5e4bc848a6c65ec4eb91f8994ab9980a5ec20fb0 /src/or/routerlist.c | |
parent | 80b515b85fdfbcd645cb1920e398b3f2f6e85a31 (diff) | |
download | tor-fe309e7ad633bee36e175e600f0b9a0ac18cf981.tar.gz tor-fe309e7ad633bee36e175e600f0b9a0ac18cf981.zip |
Implement a basic node and nodelist type
The node_t type is meant to serve two key functions:
1) Abstracting difference between routerinfo_t and microdesc_t
so that clients can use microdesc_t instead of routerinfo_t.
2) Being a central place to hold mutable state about nodes
formerly held in routerstatus_t and routerinfo_t.
This patch implements a nodelist type that holds a node for every
router that we would consider using.
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 43be8346cc..3c38f9c814 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -24,6 +24,7 @@ #include "main.h" #include "microdesc.h" #include "networkstatus.h" +#include "nodelist.h" #include "policies.h" #include "reasons.h" #include "rendcommon.h" @@ -2783,6 +2784,7 @@ routerlist_insert(routerlist_t *rl, routerinfo_t *ri) &ri->cache_info); smartlist_add(rl->routers, ri); ri->cache_info.routerlist_index = smartlist_len(rl->routers) - 1; + nodelist_add_routerinfo(ri); router_dir_info_changed(); #ifdef DEBUG_ROUTERLIST routerlist_assert_ok(rl); @@ -2890,6 +2892,8 @@ routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old, time_t now) tor_assert(0 <= idx && idx < smartlist_len(rl->routers)); tor_assert(smartlist_get(rl->routers, idx) == ri); + nodelist_remove_routerinfo(ri); + /* make sure the rephist module knows that it's not running */ rep_hist_note_router_unreachable(ri->cache_info.identity_digest, now); @@ -3011,6 +3015,9 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old, tor_assert(0 <= idx && idx < smartlist_len(rl->routers)); tor_assert(smartlist_get(rl->routers, idx) == ri_old); + nodelist_remove_routerinfo(ri_old); + nodelist_add_routerinfo(ri_new); + router_dir_info_changed(); if (idx >= 0) { smartlist_set(rl->routers, idx, ri_new); |