2 This file is part of GNUnet.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file rps/gnunet-service-rps_view.h
23 * @brief wrapper around the "local view"
24 * @author Julius Bünger
26 #include "gnunet_util_lib.h"
32 * Create an empty view.
34 * @param len the maximum length for the view
35 * @return The newly created view
38 View_create (unsigned int len);
42 * Change length of view
44 * If size is decreased, peers with higher indices are removed.
46 * @param view The view that is changed
47 * @param len the (maximum) length for the view
50 View_change_len (struct View *view,
54 * Get the view as an array
56 * @return the view in array representation
58 const struct GNUNET_PeerIdentity *
59 View_get_as_array (const struct View *view);
63 * Get the size of the view
65 * @param view The view of which the size should be returned
66 * @return current number of actually contained peers
69 View_size (const struct View *view);
73 * Insert peer into the view
75 * @param view The view to put the peer into
76 * @param peer the peer to insert
78 * @return GNUNET_OK if peer was actually inserted
79 * GNUNET_NO if peer was not inserted
82 View_put (struct View *view,
83 const struct GNUNET_PeerIdentity *peer);
87 * Check whether view contains a peer
89 * @param view The which is checked for a peer
90 * @param peer the peer to check for
92 * @return GNUNET_OK if view contains peer
96 View_contains_peer (const struct View *view,
97 const struct GNUNET_PeerIdentity *peer);
101 * Remove peer from view
103 * @param view The view of which to remove the peer
104 * @param peer the peer to remove
106 * @return GNUNET_OK if view contained peer and removed it successfully
107 * GNUNET_NO if view does not contain peer
110 View_remove_peer (struct View *view,
111 const struct GNUNET_PeerIdentity *peer);
115 * Get a peer by index
117 * @param view the view of which to get the peer
118 * @param index the index of the peer to get
120 * @return peer to the corresponding index.
121 * NULL if this index is not known
123 const struct GNUNET_PeerIdentity *
124 View_get_peer_by_index (const struct View *view,
131 * @param view The view to clear
134 View_clear (struct View *view);
140 * @param view the view to destroy
143 View_destroy (struct View *view);
145 /* end of gnunet-service-rps_view.h */