aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/messenger_api_peer_store.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/messenger_api_peer_store.h')
-rw-r--r--src/messenger/messenger_api_peer_store.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/messenger/messenger_api_peer_store.h b/src/messenger/messenger_api_peer_store.h
new file mode 100644
index 000000000..526a1ca57
--- /dev/null
+++ b/src/messenger/messenger_api_peer_store.h
@@ -0,0 +1,93 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2023 GNUnet e.V.
4
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.
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 Affero General Public License for more details.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @author Tobias Frisch
22 * @file src/messenger/messenger_api_peer_store.h
23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */
25
26#ifndef GNUNET_MESSENGER_API_PEER_STORE_H
27#define GNUNET_MESSENGER_API_PEER_STORE_H
28
29#include "platform.h"
30#include "gnunet_util_lib.h"
31
32struct GNUNET_MESSENGER_Message;
33
34struct GNUNET_MESSENGER_PeerStore
35{
36 struct GNUNET_CONTAINER_MultiShortmap *peers;
37};
38
39/**
40 * Initializes a peer store as fully empty.
41 *
42 * @param[out] store Peer store
43 */
44void
45init_peer_store (struct GNUNET_MESSENGER_PeerStore *store);
46
47/**
48 * Clears a peer store, wipes its content and deallocates its memory.
49 *
50 * @param[in,out] store Peer store
51 */
52void
53clear_peer_store (struct GNUNET_MESSENGER_PeerStore *store);
54
55/**
56 * Returns the peer identity inside the <i>store</i> which verifies the
57 * signature of a given <i>message</i> as valid. The specific peer identity
58 * has to be added to the <i>store</i> previously. Otherwise the function
59 * returns NULL.
60 *
61 * @param[in,out] store Peer store
62 * @param[in] message Message
63 * @param[in] hash Hash of message
64 * @return Peer identity or NULL
65 */
66struct GNUNET_PeerIdentity*
67get_store_peer_of (struct GNUNET_MESSENGER_PeerStore *store,
68 const struct GNUNET_MESSENGER_Message *message,
69 const struct GNUNET_HashCode *hash);
70
71/**
72 * Adds a <i>peer</i> identity to the <i>store</i> if necessary. It ensures
73 * that the given <i>peer</i> can be verified as sender of a message
74 * afterwards by the <i>store</i>.
75 *
76 * @param[in,out] store Peer store
77 * @param[in] peer Peer identity
78 */
79void
80update_store_peer (struct GNUNET_MESSENGER_PeerStore *store,
81 const struct GNUNET_PeerIdentity* peer);
82
83/**
84 * Removes a <i>peer</i> identity from the <i>store</i> entirely.
85 *
86 * @param[in,out] store Peer store
87 * @param[in] peer Peer identity
88 */
89void
90remove_store_peer (struct GNUNET_MESSENGER_PeerStore *store,
91 const struct GNUNET_PeerIdentity *peer);
92
93#endif //GNUNET_MESSENGER_API_PEER_STORE_H