#ifndef USER_DIRECTORY_H
#define USER_DIRECTORY_H
struct user {
/* Approximately sorted by time (except during handshaking).
The sorting order may be constantly wrong a few seconds here and
there. */
/* first 32 bits of MD5(username). collisions are quite unlikely, but
even if they happen it doesn't matter - the users are just
redirected to same server */
unsigned int username_hash;
unsigned int timestamp;
/* If non-NULL, don't allow new connections until all
directors have killed the user's connections. */
/* TRUE, if the user's timestamp was close to being expired and we're
now doing a ring-wide sync for this user to make sure we don't
assign conflicting hosts to it */
};
/* Create a new directory. Users are dropped if their time gets older
than timeout_secs. */
struct user_directory *
user_directory_init(unsigned int timeout_secs,
/* Returns the number of users currently in directory. */
/* Look up username from directory. Returns NULL if not found. */
unsigned int username_hash);
/* Add a user to directory and return it. */
struct user *
/* Refresh user's timestamp */
/* Remove all users that have pointers to given host */
/* Sort users based on the timestamp. This is called only after updating
timestamps based on remote director's user list after handshake. */
/* Iterate through users in the directory. It's safe to modify user directory
while iterators are running. The removed users will just be skipped over.
Users that are refreshed (= moved to end of list) may be processed twice.
Using iter_until_current_tail=TRUE causes the iterator to not iterate
Note that this may skip some users entirely. */
struct user_directory_iter *
bool iter_until_current_tail);
#endif