2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009 GNUnet e.V.
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/>.
20 * @author Christian Grothoff
23 * Helper library for interning of peer identifiers
25 * @defgroup peer Peer library
26 * Helper library for interning of peer identifiers
30 #ifndef GNUNET_PEER_LIB_H
31 #define GNUNET_PEER_LIB_H
33 #include "gnunet_util_lib.h"
38 #if 0 /* keep Emacsens' auto-indent happy */
44 * A GNUNET_PEER_Id is simply a shorter version of a "struct
45 * GNUNET_PeerIdentifier" that can be used inside of a GNUnet peer to
46 * save memory when the same identifier needs to be used over and over
49 typedef unsigned int GNUNET_PEER_Id;
53 * Search for a peer identity. The reference counter is not changed.
55 * @param pid identity to find
56 * @return the interned identity or 0.
59 GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid);
63 * Intern an peer identity. If the identity is already known, its
64 * reference counter will be increased by one.
66 * @param pid identity to intern
67 * @return the interned identity.
70 GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid);
74 * Change the reference counter of an interned PID.
76 * @param id identity to change the RC of
77 * @param delta how much to change the RC
80 GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta);
84 * Decrement multiple RCs of peer identities by one.
86 * @param ids array of PIDs to decrement the RCs of
87 * @param count size of the @a ids array
90 GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids,
95 * Convert an interned PID to a normal peer identity.
97 * @param id interned PID to convert
98 * @param pid where to write the normal peer identity
101 GNUNET_PEER_resolve (GNUNET_PEER_Id id,
102 struct GNUNET_PeerIdentity *pid);
106 * Convert an interned PID to a normal peer identity.
108 * @param id interned PID to convert
109 * @return pointer to peer identity, valid as long @a id is valid
111 const struct GNUNET_PeerIdentity *
112 GNUNET_PEER_resolve2 (GNUNET_PEER_Id id);
115 #if 0 /* keep Emacsens' auto-indent happy */
122 /* ifndef GNUNET_PEER_LIB_H */
125 /** @} */ /* end of group */
127 /* end of gnunet_peer_lib.h */