aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_message_store.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/gnunet-service-messenger_message_store.h')
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.h169
1 files changed, 0 insertions, 169 deletions
diff --git a/src/messenger/gnunet-service-messenger_message_store.h b/src/messenger/gnunet-service-messenger_message_store.h
deleted file mode 100644
index 476d98dd5..000000000
--- a/src/messenger/gnunet-service-messenger_message_store.h
+++ /dev/null
@@ -1,169 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2021 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/gnunet-service-messenger_message_store.h
23 * @brief GNUnet MESSENGER service
24 */
25
26#ifndef GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H
27#define GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H
28
29#include "platform.h"
30#include "gnunet_container_lib.h"
31#include "gnunet_disk_lib.h"
32
33struct GNUNET_MESSENGER_MessageEntry
34{
35 off_t offset;
36 uint16_t length;
37};
38
39struct GNUNET_MESSENGER_Message;
40
41struct GNUNET_MESSENGER_MessageLink
42{
43 uint8_t multiple;
44
45 struct GNUNET_HashCode first;
46 struct GNUNET_HashCode second;
47};
48
49struct GNUNET_MESSENGER_MessageStore
50{
51 struct GNUNET_DISK_FileHandle *storage_messages;
52
53 struct GNUNET_CONTAINER_MultiHashMap *entries;
54 struct GNUNET_CONTAINER_MultiHashMap *messages;
55 struct GNUNET_CONTAINER_MultiHashMap *links;
56
57 int rewrite_entries;
58 int write_links;
59};
60
61/**
62 * Initializes a message <i>store</i> as fully empty.
63 *
64 * @param[out] store Message store
65 */
66void
67init_message_store (struct GNUNET_MESSENGER_MessageStore *store);
68
69/**
70 * Clears a message <i>store</i>, wipes its content and deallocates its memory.
71 *
72 * @param[in/out] store Message store
73 */
74void
75clear_message_store (struct GNUNET_MESSENGER_MessageStore *store);
76
77/**
78 * Loads messages from a <i>directory</i> into a message <i>store</i>.
79 *
80 * @param[out] store Message store
81 * @param[in] directory Path to a directory
82 */
83void
84load_message_store (struct GNUNET_MESSENGER_MessageStore *store,
85 const char *directory);
86
87/**
88 * Saves messages from a message <i>store</i> into a <i>directory</i>.
89 *
90 * @param[in] store Message store
91 * @param[in] directory Path to a directory
92 */
93void
94save_message_store (struct GNUNET_MESSENGER_MessageStore *store,
95 const char *directory);
96
97/**
98 * Checks if a message matching a given <i>hash</i> is stored in a message <i>store</i>.
99 * The function returns #GNUNET_YES if a match is found, #GNUNET_NO otherwise.
100 *
101 * The message has not to be loaded from disk into memory for this check!
102 *
103 * @param[in] store Message store
104 * @param[in] hash Hash of message
105 * @return #GNUNET_YES on match, otherwise #GNUNET_NO
106 */
107int
108contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store,
109 const struct GNUNET_HashCode *hash);
110
111/**
112 * Returns the message from a message <i>store</i> matching a given <i>hash</i>. If no matching
113 * message is found, NULL gets returned.
114 *
115 * This function requires the message to be loaded into memory!
116 * @see contains_store_message()
117 *
118 * @param[in/out] store Message store
119 * @param[in] hash Hash of message
120 * @return Message or NULL
121 */
122const struct GNUNET_MESSENGER_Message*
123get_store_message (struct GNUNET_MESSENGER_MessageStore *store,
124 const struct GNUNET_HashCode *hash);
125
126/**
127 * Returns the message link from a message <i>store</i> matching a given <i>hash</i>. If the
128 * flag is set to #GNUNET_YES, only links from deleted messages will be returned or NULL.
129 *
130 * Otherwise message links will also returned for messages found in the store under the given
131 * hash. The link which will be returned copies link information from the message for
132 * temporary usage.
133 *
134 * @param[in/out] store Message store
135 * @param[in] hash Hash of message
136 * @param[in] deleted_only Flag
137 * @return Message link or NULL
138 */
139const struct GNUNET_MESSENGER_MessageLink*
140get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store,
141 const struct GNUNET_HashCode *hash,
142 int deleted_only);
143
144/**
145 * Stores a message into the message store. The result indicates if the operation was successful.
146 *
147 * @param[in/out] store Message store
148 * @param[in] hash Hash of message
149 * @param[in/out] message Message
150 * @return #GNUNET_OK on success, otherwise #GNUNET_NO
151 */
152int
153put_store_message (struct GNUNET_MESSENGER_MessageStore *store,
154 const struct GNUNET_HashCode *hash,
155 struct GNUNET_MESSENGER_Message *message);
156
157/**
158 * Deletes a message in the message store. It will be removed from disk space and memory. The result
159 * indicates if the operation was successful.
160 *
161 * @param[in/out] store Message store
162 * @param[in] hash Hash of message
163 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
164 */
165int
166delete_store_message (struct GNUNET_MESSENGER_MessageStore *store,
167 const struct GNUNET_HashCode *hash);
168
169#endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H