update velocity always at the end of iteration
[oweals/gnunet.git] / src / rps / gnunet-service-rps_view.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file rps/gnunet-service-rps_view.h
23  * @brief wrapper around the "local view"
24  * @author Julius Bünger
25  */
26 #include "gnunet_util_lib.h"
27 #include <inttypes.h>
28
29
30 /**
31  * Create an empty view.
32  *
33  * @param len the maximum length for the view
34  */
35 void
36 View_create (unsigned int len);
37
38 /**
39  * Change length of view
40  *
41  * If size is decreased, peers with higher indices are removed.
42  *
43  * @param len the (maximum) length for the view
44  */
45 void
46 View_change_len (unsigned int len);
47
48 /**
49  * Get the view as an array
50  *
51  * @return the view in array representation
52  */
53 const struct GNUNET_PeerIdentity *
54 View_get_as_array ();
55
56 /**
57  * Get the size of the view
58  *
59  * @return current number of actually contained peers
60  */
61 unsigned int
62 View_size ();
63
64 /**
65  * Insert peer into the view
66  *
67  * @param peer the peer to insert
68  *
69  * @return GNUNET_OK if peer was actually inserted
70  *         GNUNET_NO if peer was not inserted
71  */
72 int
73 View_put (const struct GNUNET_PeerIdentity *peer);
74
75 /**
76  * Check whether view contains a peer
77  *
78  * @param peer the peer to check for
79  *
80  * @return GNUNET_OK if view contains peer
81  *         GNUNET_NO otherwise
82  */
83 int
84 View_contains_peer (const struct GNUNET_PeerIdentity *peer);
85
86 /**
87  * Remove peer from view
88  *
89  * @param peer the peer to remove
90  *
91  * @return GNUNET_OK if view contained peer and removed it successfully
92  *         GNUNET_NO if view does not contain peer
93  */
94 int
95 View_remove_peer (const struct GNUNET_PeerIdentity *peer);
96
97 /**
98  * Get a peer by index
99  *
100  * @param index the index of the peer to get
101  *
102  * @return peer to the corresponding index.
103  *         NULL if this index is not known
104  */
105 const struct GNUNET_PeerIdentity *
106 View_get_peer_by_index (uint32_t index);
107
108 /**
109  * Clear the custom peer map
110  *
111  * @param c_peer_map the custom peer map to look in
112  *
113  * @return size of the map
114  */
115 void
116 View_clear ();
117
118 /**
119  * Destroy peermap.
120  *
121  * @param c_peer_map the map to destroy
122  */
123 void
124 View_destroy ();
125
126 /* end of gnunet-service-rps_view.h */