diff options
author | Julius Bünger <buenger@mytum.de> | 2015-02-07 16:19:34 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-02-07 16:19:34 +0000 |
commit | 9faea17ef30144323b311e282238f5caaabe451e (patch) | |
tree | b66df9c6bff36959b44889f18a5414dae2e0df66 /src/rps/gnunet-service-rps_sampler.h | |
parent | b85b68adb5960859e735319eb27a0d1594020d52 (diff) | |
download | gnunet-9faea17ef30144323b311e282238f5caaabe451e.tar.gz gnunet-9faea17ef30144323b311e282238f5caaabe451e.zip |
distinct samplers for client and Brahms protocol
Diffstat (limited to 'src/rps/gnunet-service-rps_sampler.h')
-rw-r--r-- | src/rps/gnunet-service-rps_sampler.h | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/src/rps/gnunet-service-rps_sampler.h b/src/rps/gnunet-service-rps_sampler.h index bc3994e36..3bbfc2a40 100644 --- a/src/rps/gnunet-service-rps_sampler.h +++ b/src/rps/gnunet-service-rps_sampler.h | |||
@@ -28,6 +28,13 @@ | |||
28 | #define RPS_SAMPLER_H | 28 | #define RPS_SAMPLER_H |
29 | #include <inttypes.h> | 29 | #include <inttypes.h> |
30 | 30 | ||
31 | |||
32 | /** | ||
33 | * A sampler sampling a stream of PeerIDs. | ||
34 | */ | ||
35 | struct RPS_Sampler; | ||
36 | |||
37 | |||
31 | /** | 38 | /** |
32 | * Callback that is called when a new PeerID is inserted into a sampler. | 39 | * Callback that is called when a new PeerID is inserted into a sampler. |
33 | * | 40 | * |
@@ -36,6 +43,7 @@ | |||
36 | */ | 43 | */ |
37 | typedef void | 44 | typedef void |
38 | (*RPS_sampler_insert_cb) (void *cls, | 45 | (*RPS_sampler_insert_cb) (void *cls, |
46 | struct RPS_Sampler *sampler, | ||
39 | const struct GNUNET_PeerIdentity *id); | 47 | const struct GNUNET_PeerIdentity *id); |
40 | 48 | ||
41 | /** | 49 | /** |
@@ -46,6 +54,7 @@ typedef void | |||
46 | */ | 54 | */ |
47 | typedef void | 55 | typedef void |
48 | (*RPS_sampler_remove_cb) (void *cls, | 56 | (*RPS_sampler_remove_cb) (void *cls, |
57 | struct RPS_Sampler *sampler, | ||
49 | const struct GNUNET_PeerIdentity *id); | 58 | const struct GNUNET_PeerIdentity *id); |
50 | 59 | ||
51 | /** | 60 | /** |
@@ -61,26 +70,23 @@ typedef void | |||
61 | 70 | ||
62 | 71 | ||
63 | /** | 72 | /** |
64 | * A sampler sampling a stream of PeerIDs. | ||
65 | */ | ||
66 | //struct RPS_Sampler; | ||
67 | |||
68 | /** | ||
69 | * Get the size of the sampler. | 73 | * Get the size of the sampler. |
70 | * | 74 | * |
75 | * @param sampler the sampler to return the size of. | ||
71 | * @return the size of the sampler | 76 | * @return the size of the sampler |
72 | */ | 77 | */ |
73 | unsigned int | 78 | unsigned int |
74 | RPS_sampler_get_size (); | 79 | RPS_sampler_get_size (struct RPS_Sampler *sampler); |
75 | 80 | ||
76 | 81 | ||
77 | /** | 82 | /** |
78 | * Grow or shrink the size of the sampler. | 83 | * Grow or shrink the size of the sampler. |
79 | * | 84 | * |
85 | * @param sampler the sampler to resize. | ||
80 | * @param new_size the new size of the sampler (not 0) | 86 | * @param new_size the new size of the sampler (not 0) |
81 | */ | 87 | */ |
82 | void | 88 | void |
83 | RPS_sampler_resize (unsigned int new_size); | 89 | RPS_sampler_resize (struct RPS_Sampler *sampler, unsigned int new_size); |
84 | 90 | ||
85 | 91 | ||
86 | /** | 92 | /** |
@@ -94,8 +100,9 @@ RPS_sampler_resize (unsigned int new_size); | |||
94 | * @param rem_cb the callback that will be called on every PeerID that is | 100 | * @param rem_cb the callback that will be called on every PeerID that is |
95 | * removed from a sampler element | 101 | * removed from a sampler element |
96 | * @param rem_cls the closure given to #rem_cb | 102 | * @param rem_cls the closure given to #rem_cb |
103 | * @return a handle to a sampler that consists of sampler elements. | ||
97 | */ | 104 | */ |
98 | void | 105 | struct RPS_Sampler * |
99 | RPS_sampler_init (size_t init_size, | 106 | RPS_sampler_init (size_t init_size, |
100 | struct GNUNET_TIME_Relative max_round_interval, | 107 | struct GNUNET_TIME_Relative max_round_interval, |
101 | RPS_sampler_insert_cb ins_cb, void *ins_cls, | 108 | RPS_sampler_insert_cb ins_cb, void *ins_cls, |
@@ -105,21 +112,26 @@ RPS_sampler_init (size_t init_size, | |||
105 | /** | 112 | /** |
106 | * A fuction to update every sampler in the given list | 113 | * A fuction to update every sampler in the given list |
107 | * | 114 | * |
115 | * @param sampler the sampler to update. | ||
108 | * @param id the PeerID that is put in the sampler | 116 | * @param id the PeerID that is put in the sampler |
109 | */ | 117 | */ |
110 | void | 118 | void |
111 | RPS_sampler_update_list (const struct GNUNET_PeerIdentity *id); | 119 | RPS_sampler_update (struct RPS_Sampler *sampler, |
120 | const struct GNUNET_PeerIdentity *id); | ||
112 | 121 | ||
113 | 122 | ||
114 | /** | 123 | /** |
115 | * Reinitialise all previously initialised sampler elements with the given value. | 124 | * Reinitialise all previously initialised sampler elements with the given |
125 | * value. | ||
116 | * | 126 | * |
117 | * Used to get rid of a PeerID. | 127 | * Used to get rid of a PeerID. |
118 | * | 128 | * |
129 | * @param sampler the sampler to reinitialise a sampler in. | ||
119 | * @param id the id of the samplers to update. | 130 | * @param id the id of the samplers to update. |
120 | */ | 131 | */ |
121 | void | 132 | void |
122 | RPS_sampler_reinitialise_by_value (const struct GNUNET_PeerIdentity *id); | 133 | RPS_sampler_reinitialise_by_value (struct RPS_Sampler *sampler, |
134 | const struct GNUNET_PeerIdentity *id); | ||
123 | 135 | ||
124 | 136 | ||
125 | /** | 137 | /** |
@@ -129,6 +141,7 @@ RPS_sampler_reinitialise_by_value (const struct GNUNET_PeerIdentity *id); | |||
129 | * corrsponding peer to the client. | 141 | * corrsponding peer to the client. |
130 | * Random with or without consumption? | 142 | * Random with or without consumption? |
131 | * | 143 | * |
144 | * @param sampler the sampler to get peers from. | ||
132 | * @param cb callback that will be called once the ids are ready. | 145 | * @param cb callback that will be called once the ids are ready. |
133 | * @param cls closure given to @a cb | 146 | * @param cls closure given to @a cb |
134 | * @param for_client #GNUNET_YES if result is used for client, | 147 | * @param for_client #GNUNET_YES if result is used for client, |
@@ -136,26 +149,31 @@ RPS_sampler_reinitialise_by_value (const struct GNUNET_PeerIdentity *id); | |||
136 | * @param num_peers the number of peers requested | 149 | * @param num_peers the number of peers requested |
137 | */ | 150 | */ |
138 | void | 151 | void |
139 | RPS_sampler_get_n_rand_peers (RPS_sampler_n_rand_peers_ready_cb cb, | 152 | RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, |
140 | void *cls, uint32_t num_peers, int for_client); | 153 | RPS_sampler_n_rand_peers_ready_cb cb, |
154 | void *cls, uint32_t num_peers, int for_client); | ||
141 | 155 | ||
142 | 156 | ||
143 | /** | 157 | /** |
144 | * Counts how many Samplers currently hold a given PeerID. | 158 | * Counts how many Samplers currently hold a given PeerID. |
145 | * | 159 | * |
160 | * @param sampler the sampler to cound ids in. | ||
146 | * @param id the PeerID to count. | 161 | * @param id the PeerID to count. |
147 | * | 162 | * |
148 | * @return the number of occurrences of id. | 163 | * @return the number of occurrences of id. |
149 | */ | 164 | */ |
150 | uint32_t | 165 | uint32_t |
151 | RPS_sampler_count_id (const struct GNUNET_PeerIdentity *id); | 166 | RPS_sampler_count_id (struct RPS_Sampler *sampler, |
167 | const struct GNUNET_PeerIdentity *id); | ||
152 | 168 | ||
153 | 169 | ||
154 | /** | 170 | /** |
155 | * Cleans the samplers. | 171 | * Cleans the samplers. |
172 | * | ||
173 | * @param sampler the sampler to destroy. | ||
156 | */ | 174 | */ |
157 | void | 175 | void |
158 | RPS_sampler_destroy (); | 176 | RPS_sampler_destroy (struct RPS_Sampler *sampler); |
159 | 177 | ||
160 | #endif | 178 | #endif |
161 | /* end of gnunet-service-rps.c */ | 179 | /* end of gnunet-service-rps.c */ |