diff options
author | Julius Bünger <buenger@mytum.de> | 2018-10-01 20:05:40 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-10-01 23:15:31 +0200 |
commit | 3823c7a71aa1b16df6c34ef3def45875289a6b3d (patch) | |
tree | 14fa9b007663823983fad8194202e8441a4588c0 /src/rps/gnunet-service-rps_view.h | |
parent | b3aad5bef2e78487251ef7fc766a510f9fc731c9 (diff) | |
download | gnunet-3823c7a71aa1b16df6c34ef3def45875289a6b3d.tar.gz gnunet-3823c7a71aa1b16df6c34ef3def45875289a6b3d.zip |
Restructure implementation of view (towards subsampling)
Diffstat (limited to 'src/rps/gnunet-service-rps_view.h')
-rw-r--r-- | src/rps/gnunet-service-rps_view.h | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/src/rps/gnunet-service-rps_view.h b/src/rps/gnunet-service-rps_view.h index 127b49faf..a9017bab8 100644 --- a/src/rps/gnunet-service-rps_view.h +++ b/src/rps/gnunet-service-rps_view.h | |||
@@ -24,24 +24,29 @@ | |||
24 | #include "gnunet_util_lib.h" | 24 | #include "gnunet_util_lib.h" |
25 | #include <inttypes.h> | 25 | #include <inttypes.h> |
26 | 26 | ||
27 | struct View; | ||
27 | 28 | ||
28 | /** | 29 | /** |
29 | * Create an empty view. | 30 | * Create an empty view. |
30 | * | 31 | * |
31 | * @param len the maximum length for the view | 32 | * @param len the maximum length for the view |
33 | * @return The newly created view | ||
32 | */ | 34 | */ |
33 | void | 35 | struct View * |
34 | View_create (unsigned int len); | 36 | View_create (unsigned int len); |
35 | 37 | ||
38 | |||
36 | /** | 39 | /** |
37 | * Change length of view | 40 | * Change length of view |
38 | * | 41 | * |
39 | * If size is decreased, peers with higher indices are removed. | 42 | * If size is decreased, peers with higher indices are removed. |
40 | * | 43 | * |
44 | * @param view The view that is changed | ||
41 | * @param len the (maximum) length for the view | 45 | * @param len the (maximum) length for the view |
42 | */ | 46 | */ |
43 | void | 47 | void |
44 | View_change_len (unsigned int len); | 48 | View_change_len (struct View *view, |
49 | unsigned int len); | ||
45 | 50 | ||
46 | /** | 51 | /** |
47 | * Get the view as an array | 52 | * Get the view as an array |
@@ -49,76 +54,90 @@ View_change_len (unsigned int len); | |||
49 | * @return the view in array representation | 54 | * @return the view in array representation |
50 | */ | 55 | */ |
51 | const struct GNUNET_PeerIdentity * | 56 | const struct GNUNET_PeerIdentity * |
52 | View_get_as_array (); | 57 | View_get_as_array (const struct View *view); |
58 | |||
53 | 59 | ||
54 | /** | 60 | /** |
55 | * Get the size of the view | 61 | * Get the size of the view |
56 | * | 62 | * |
63 | * @param view The view of which the size should be returned | ||
57 | * @return current number of actually contained peers | 64 | * @return current number of actually contained peers |
58 | */ | 65 | */ |
59 | unsigned int | 66 | unsigned int |
60 | View_size (); | 67 | View_size (const struct View *view); |
68 | |||
61 | 69 | ||
62 | /** | 70 | /** |
63 | * Insert peer into the view | 71 | * Insert peer into the view |
64 | * | 72 | * |
73 | * @param view The view to put the peer into | ||
65 | * @param peer the peer to insert | 74 | * @param peer the peer to insert |
66 | * | 75 | * |
67 | * @return GNUNET_OK if peer was actually inserted | 76 | * @return GNUNET_OK if peer was actually inserted |
68 | * GNUNET_NO if peer was not inserted | 77 | * GNUNET_NO if peer was not inserted |
69 | */ | 78 | */ |
70 | int | 79 | int |
71 | View_put (const struct GNUNET_PeerIdentity *peer); | 80 | View_put (struct View *view, |
81 | const struct GNUNET_PeerIdentity *peer); | ||
82 | |||
72 | 83 | ||
73 | /** | 84 | /** |
74 | * Check whether view contains a peer | 85 | * Check whether view contains a peer |
75 | * | 86 | * |
87 | * @param view The which is checked for a peer | ||
76 | * @param peer the peer to check for | 88 | * @param peer the peer to check for |
77 | * | 89 | * |
78 | * @return GNUNET_OK if view contains peer | 90 | * @return GNUNET_OK if view contains peer |
79 | * GNUNET_NO otherwise | 91 | * GNUNET_NO otherwise |
80 | */ | 92 | */ |
81 | int | 93 | int |
82 | View_contains_peer (const struct GNUNET_PeerIdentity *peer); | 94 | View_contains_peer (const struct View *view, |
95 | const struct GNUNET_PeerIdentity *peer); | ||
96 | |||
83 | 97 | ||
84 | /** | 98 | /** |
85 | * Remove peer from view | 99 | * Remove peer from view |
86 | * | 100 | * |
101 | * @param view The view of which to remove the peer | ||
87 | * @param peer the peer to remove | 102 | * @param peer the peer to remove |
88 | * | 103 | * |
89 | * @return GNUNET_OK if view contained peer and removed it successfully | 104 | * @return GNUNET_OK if view contained peer and removed it successfully |
90 | * GNUNET_NO if view does not contain peer | 105 | * GNUNET_NO if view does not contain peer |
91 | */ | 106 | */ |
92 | int | 107 | int |
93 | View_remove_peer (const struct GNUNET_PeerIdentity *peer); | 108 | View_remove_peer (struct View *view, |
109 | const struct GNUNET_PeerIdentity *peer); | ||
110 | |||
94 | 111 | ||
95 | /** | 112 | /** |
96 | * Get a peer by index | 113 | * Get a peer by index |
97 | * | 114 | * |
115 | * @param view the view of which to get the peer | ||
98 | * @param index the index of the peer to get | 116 | * @param index the index of the peer to get |
99 | * | 117 | * |
100 | * @return peer to the corresponding index. | 118 | * @return peer to the corresponding index. |
101 | * NULL if this index is not known | 119 | * NULL if this index is not known |
102 | */ | 120 | */ |
103 | const struct GNUNET_PeerIdentity * | 121 | const struct GNUNET_PeerIdentity * |
104 | View_get_peer_by_index (uint32_t index); | 122 | View_get_peer_by_index (const struct View *view, |
123 | uint32_t index); | ||
124 | |||
105 | 125 | ||
106 | /** | 126 | /** |
107 | * Clear the custom peer map | 127 | * Clear the view |
108 | * | 128 | * |
109 | * @param c_peer_map the custom peer map to look in | 129 | * @param view The view to clear |
110 | * | ||
111 | * @return size of the map | ||
112 | */ | 130 | */ |
113 | void | 131 | void |
114 | View_clear (); | 132 | View_clear (struct View *view); |
133 | |||
115 | 134 | ||
116 | /** | 135 | /** |
117 | * Destroy peermap. | 136 | * Destroy view. |
118 | * | 137 | * |
119 | * @param c_peer_map the map to destroy | 138 | * @param view the view to destroy |
120 | */ | 139 | */ |
121 | void | 140 | void |
122 | View_destroy (); | 141 | View_destroy (struct View *view); |
123 | 142 | ||
124 | /* end of gnunet-service-rps_view.h */ | 143 | /* end of gnunet-service-rps_view.h */ |