2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @file include/gnunet_peer_lib.h
23 * @brief helper library for interning of peer identifiers
24 * @author Christian Grothoff
27 #ifndef GNUNET_PEER_LIB_H
28 #define GNUNET_PEER_LIB_H
30 #include "gnunet_util_lib.h"
35 #if 0 /* keep Emacsens' auto-indent happy */
41 * A GNUNET_PEER_Id is simply a shorter version of a "struct
42 * GNUNET_PeerIdentifier" that can be used inside of a GNUnet peer to
43 * save memory when the same identifier needs to be used over and over
46 typedef unsigned int GNUNET_PEER_Id;
50 * Search for a peer identity. The reference counter is not changed.
52 * @param pid identity to find
53 * @return the interned identity or 0.
56 GNUNET_PEER_search (const struct GNUNET_PeerIdentity *pid);
60 * Intern an peer identity. If the identity is already known, its
61 * reference counter will be increased by one.
63 * @param pid identity to intern
64 * @return the interned identity.
67 GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid);
71 * Change the reference counter of an interned PID.
73 * @param id identity to change the RC of
74 * @param delta how much to change the RC
77 GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta);
81 * Decrement multiple RCs of peer identities by one.
83 * @param ids array of PIDs to decrement the RCs of
84 * @param count size of the @a ids array
87 GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids,
92 * Convert an interned PID to a normal peer identity.
94 * @param id interned PID to convert
95 * @param pid where to write the normal peer identity
98 GNUNET_PEER_resolve (GNUNET_PEER_Id id,
99 struct GNUNET_PeerIdentity *pid);
103 * Convert an interned PID to a normal peer identity.
105 * @param id interned PID to convert
106 * @return pointer to peer identity, valid as long @a id is valid
108 const struct GNUNET_PeerIdentity *
109 GNUNET_PEER_resolve2 (GNUNET_PEER_Id id);
112 #if 0 /* keep Emacsens' auto-indent happy */
120 /* ifndef GNUNET_PEER_LIB_H */
122 /* end of gnunet_peer_lib.h */