aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-service-rps_view.h
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-11-29 20:44:44 +0000
committerJulius Bünger <buenger@mytum.de>2015-11-29 20:44:44 +0000
commitd72d8e05401ace44b57432463f136bcfe55cee03 (patch)
tree8d1374ae5ebd8aa7eb7b5be6ee4d88b7fa78c298 /src/rps/gnunet-service-rps_view.h
parenta0e27c0bd09fc4b0d70295baa5d7e052c46fe4ff (diff)
downloadgnunet-d72d8e05401ace44b57432463f136bcfe55cee03.tar.gz
gnunet-d72d8e05401ace44b57432463f136bcfe55cee03.zip
added helper for handling the "view" in rps
Signed-off-by: Julius Bünger <buenger@mytum.de>
Diffstat (limited to 'src/rps/gnunet-service-rps_view.h')
-rw-r--r--src/rps/gnunet-service-rps_view.h124
1 files changed, 124 insertions, 0 deletions
diff --git a/src/rps/gnunet-service-rps_view.h b/src/rps/gnunet-service-rps_view.h
new file mode 100644
index 000000000..e05823013
--- /dev/null
+++ b/src/rps/gnunet-service-rps_view.h
@@ -0,0 +1,124 @@
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 */
35void
36View_create (unsigned int len);
37
38/**
39 * Change length of view
40 *
41 * @param len the (maximum) length for the view
42 */
43void
44View_change_len (unsigned int len);
45
46/**
47 * Get the view as an array
48 *
49 * @return the view in array representation
50 */
51const struct GNUNET_PeerIdentity *
52View_get_as_array ();
53
54/**
55 * Get the size of the view
56 *
57 * @return current number of actually contained peers
58 */
59unsigned int
60View_size ();
61
62/**
63 * Insert peer into the view
64 *
65 * @param peer the peer to insert
66 *
67 * @return GNUNET_OK if peer was actually inserted
68 * GNUNET_NO if peer was not inserted
69 */
70int
71View_put (const struct GNUNET_PeerIdentity *peer);
72
73/**
74 * Check whether view contains a peer
75 *
76 * @param peer the peer to check for
77 *
78 * @return GNUNET_OK if view contains peer
79 * GNUNET_NO otherwise
80 */
81int
82View_contains_peer (const struct GNUNET_PeerIdentity *peer);
83
84/**
85 * Remove peer from view
86 *
87 * @param peer the peer to remove
88 *
89 * @return GNUNET_OK if view contained peer and removed it successfully
90 * GNUNET_NO if view does not contain peer
91 */
92int
93View_remove_peer (const struct GNUNET_PeerIdentity *peer);
94
95/**
96 * Get a peer by index
97 *
98 * @param index the index of the peer to get
99 *
100 * @return peer to the corresponding index.
101 * NULL if this index is not known
102 */
103const struct GNUNET_PeerIdentity *
104View_get_peer_by_index (uint32_t index);
105
106/**
107 * Clear the custom peer map
108 *
109 * @param c_peer_map the custom peer map to look in
110 *
111 * @return size of the map
112 */
113void
114View_clear ();
115
116/**
117 * Destroy peermap.
118 *
119 * @param c_peer_map the map to destroy
120 */
121void
122View_destroy ();
123
124/* end of gnunet-service-rps_view.h */