Macros | Typedefs | Functions
dircollate.h File Reference

Header file for dircollate.c. More...

#include "lib/testsupport/testsupport.h"
#include "core/or/or.h"

Go to the source code of this file.


#define dircollator_free(c)    FREE_AND_NULL(dircollator_t, dircollator_free_, (c))


typedef struct dircollator_t dircollator_t


dircollator_t * dircollator_new (int n_votes, int n_authorities)
void dircollator_free_ (dircollator_t *obj)
void dircollator_add_vote (dircollator_t *dc, networkstatus_t *v)
void dircollator_collate (dircollator_t *dc, int consensus_method)
int dircollator_n_routers (dircollator_t *dc)
vote_routerstatus_t ** dircollator_get_votes_for_router (dircollator_t *dc, int idx)

Detailed Description

Header file for dircollate.c.

Definition in file dircollate.h.

Function Documentation

◆ dircollator_add_vote()

void dircollator_add_vote ( dircollator_t *  dc,
networkstatus_t v 

Add a single vote v to a dircollator dc. This function must be called exactly once for each vote to be used in the consensus. It may only be called before dircollator_collate().

Definition at line 194 of file dircollate.c.

◆ dircollator_collate()

void dircollator_collate ( dircollator_t *  dc,
int  consensus_method 

Sort the entries in dc according to consensus_method, so that the consensus process can iterate over them with dircollator_n_routers() and dircollator_get_votes_for_router().

Definition at line 211 of file dircollate.c.

◆ dircollator_free_()

void dircollator_free_ ( dircollator_t *  dc)

Release all storage held by dc.

Definition at line 166 of file dircollate.c.

◆ dircollator_get_votes_for_router()

vote_routerstatus_t** dircollator_get_votes_for_router ( dircollator_t *  dc,
int  idx 

Return an array of vote_routerstatus_t entries for the idxth router in the collation order. Each array contains n_votes elements, where the nth element of the array is the vote_routerstatus_t from the nth voter for this identity (or NULL if there is no such entry).

The maximum value for idx is dircollator_n_routers().

This function may only be called after dircollator_collate.

Definition at line 320 of file dircollate.c.

◆ dircollator_n_routers()

int dircollator_n_routers ( dircollator_t *  dc)

Return the total number of collated router entries. This function may only be called after dircollator_collate.

Definition at line 305 of file dircollate.c.

◆ dircollator_new()

dircollator_t* dircollator_new ( int  n_votes,
int  n_authorities 

Create and return a new dircollator object to use when collating n_votes out of a total of n_authorities.

Definition at line 149 of file dircollate.c.