aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-service-rps_view.h
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-10-01 20:05:40 +0200
committerJulius Bünger <buenger@mytum.de>2018-10-01 23:15:31 +0200
commit3823c7a71aa1b16df6c34ef3def45875289a6b3d (patch)
tree14fa9b007663823983fad8194202e8441a4588c0 /src/rps/gnunet-service-rps_view.h
parentb3aad5bef2e78487251ef7fc766a510f9fc731c9 (diff)
downloadgnunet-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.h51
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
27struct 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 */
33void 35struct View *
34View_create (unsigned int len); 36View_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 */
43void 47void
44View_change_len (unsigned int len); 48View_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 */
51const struct GNUNET_PeerIdentity * 56const struct GNUNET_PeerIdentity *
52View_get_as_array (); 57View_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 */
59unsigned int 66unsigned int
60View_size (); 67View_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 */
70int 79int
71View_put (const struct GNUNET_PeerIdentity *peer); 80View_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 */
81int 93int
82View_contains_peer (const struct GNUNET_PeerIdentity *peer); 94View_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 */
92int 107int
93View_remove_peer (const struct GNUNET_PeerIdentity *peer); 108View_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 */
103const struct GNUNET_PeerIdentity * 121const struct GNUNET_PeerIdentity *
104View_get_peer_by_index (uint32_t index); 122View_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 */
113void 131void
114View_clear (); 132View_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 */
121void 140void
122View_destroy (); 141View_destroy (struct View *view);
123 142
124/* end of gnunet-service-rps_view.h */ 143/* end of gnunet-service-rps_view.h */