diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_message_store.h')
-rw-r--r-- | src/messenger/gnunet-service-messenger_message_store.h | 162 |
1 files changed, 0 insertions, 162 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 87305826a..000000000 --- a/src/messenger/gnunet-service-messenger_message_store.h +++ /dev/null | |||
@@ -1,162 +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 | |||
33 | struct GNUNET_MESSENGER_MessageEntry | ||
34 | { | ||
35 | off_t offset; | ||
36 | uint16_t length; | ||
37 | }; | ||
38 | |||
39 | struct GNUNET_MESSENGER_Message; | ||
40 | |||
41 | struct GNUNET_MESSENGER_MessageLink | ||
42 | { | ||
43 | uint8_t multiple; | ||
44 | |||
45 | struct GNUNET_HashCode first; | ||
46 | struct GNUNET_HashCode second; | ||
47 | }; | ||
48 | |||
49 | struct 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 | */ | ||
66 | void | ||
67 | init_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 | */ | ||
74 | void | ||
75 | clear_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 | */ | ||
83 | void | ||
84 | load_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory); | ||
85 | |||
86 | /** | ||
87 | * Saves messages from a message <i>store</i> into a <i>directory</i>. | ||
88 | * | ||
89 | * @param[in] store Message store | ||
90 | * @param[in] directory Path to a directory | ||
91 | */ | ||
92 | void | ||
93 | save_message_store (struct GNUNET_MESSENGER_MessageStore *store, const char *directory); | ||
94 | |||
95 | /** | ||
96 | * Checks if a message matching a given <i>hash</i> is stored in a message <i>store</i>. | ||
97 | * The function returns #GNUNET_YES if a match is found, #GNUNET_NO otherwise. | ||
98 | * | ||
99 | * The message has not to be loaded from disk into memory for this check! | ||
100 | * | ||
101 | * @param[in] store Message store | ||
102 | * @param[in] hash Hash of message | ||
103 | * @return #GNUNET_YES on match, otherwise #GNUNET_NO | ||
104 | */ | ||
105 | int | ||
106 | contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash); | ||
107 | |||
108 | /** | ||
109 | * Returns the message from a message <i>store</i> matching a given <i>hash</i>. If no matching | ||
110 | * message is found, NULL gets returned. | ||
111 | * | ||
112 | * This function requires the message to be loaded into memory! | ||
113 | * @see contains_store_message() | ||
114 | * | ||
115 | * @param[in/out] store Message store | ||
116 | * @param[in] hash Hash of message | ||
117 | * @return Message or NULL | ||
118 | */ | ||
119 | const struct GNUNET_MESSENGER_Message* | ||
120 | get_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash); | ||
121 | |||
122 | /** | ||
123 | * Returns the message link from a message <i>store</i> matching a given <i>hash</i>. If the | ||
124 | * flag is set to #GNUNET_YES, only links from deleted messages will be returned or NULL. | ||
125 | * | ||
126 | * Otherwise message links will also returned for messages found in the store under the given | ||
127 | * hash. The link which will be returned copies link information from the message for | ||
128 | * temporary usage. | ||
129 | * | ||
130 | * @param[in/out] store Message store | ||
131 | * @param[in] hash Hash of message | ||
132 | * @param[in] deleted_only Flag | ||
133 | * @return Message link or NULL | ||
134 | */ | ||
135 | const struct GNUNET_MESSENGER_MessageLink* | ||
136 | get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | ||
137 | int deleted_only); | ||
138 | |||
139 | /** | ||
140 | * Stores a message into the message store. The result indicates if the operation was successful. | ||
141 | * | ||
142 | * @param[in/out] store Message store | ||
143 | * @param[in] hash Hash of message | ||
144 | * @param[in/out] message Message | ||
145 | * @return #GNUNET_OK on success, otherwise #GNUNET_NO | ||
146 | */ | ||
147 | int | ||
148 | put_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, | ||
149 | struct GNUNET_MESSENGER_Message *message); | ||
150 | |||
151 | /** | ||
152 | * Deletes a message in the message store. It will be removed from disk space and memory. The result | ||
153 | * indicates if the operation was successful. | ||
154 | * | ||
155 | * @param[in/out] store Message store | ||
156 | * @param[in] hash Hash of message | ||
157 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | ||
158 | */ | ||
159 | int | ||
160 | delete_store_message (struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash); | ||
161 | |||
162 | #endif //GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H | ||