GNUnet 0.21.1
fs_namespace.c File Reference

publishing to namespaces, and tracking updateable entries for our namespaces More...

#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_signatures.h"
#include "gnunet_util_lib.h"
#include "gnunet_fs_service.h"
#include "fs_api.h"
#include "fs_publish_ublock.h"
Include dependency graph for fs_namespace.c:

Go to the source code of this file.

Data Structures

struct  NamespaceUpdateNode
 Information about an (updateable) node in the namespace. More...
 
struct  GNUNET_FS_UpdateInformationGraph
 Handle to update information for a namespace. More...
 
struct  GNUNET_FS_PublishSksContext
 Context for the SKS publication. More...
 
struct  ProcessUpdateClosure
 Closure for 'process_update_node'. More...
 
struct  FindTreeClosure
 Closure for 'find_trees'. More...
 

Functions

static char * get_update_information_directory (struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
 Return the name of the directory in which we store the update information graph for the given local namespace. More...
 
static void free_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
 Release memory occupied by UIG datastructure. More...
 
static void write_update_information_graph (struct GNUNET_FS_UpdateInformationGraph *uig)
 Write a namespace's update node graph to a file. More...
 
static struct GNUNET_FS_UpdateInformationGraphread_update_information_graph (struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
 Read the namespace update node graph from a file. More...
 
static void sks_publish_cont (void *cls, const char *msg)
 Function called by the UBlock construction with the result from the PUT (UBlock) request. More...
 
struct GNUNET_FS_PublishSksContextGNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *identifier, const char *update, const struct GNUNET_FS_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
 Publish an SBlock on GNUnet. More...
 
void GNUNET_FS_publish_sks_cancel (struct GNUNET_FS_PublishSksContext *psc)
 Abort the SKS publishing operation. More...
 
static int process_update_node (void *cls, const struct GNUNET_HashCode *key, void *value)
 Call the iterator in the closure for each node. More...
 
static int find_trees (void *cls, const struct GNUNET_HashCode *key, void *value)
 Find all nodes reachable from the current node (including the current node itself). More...
 
void GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *next_id, GNUNET_FS_IdentifierProcessor ip, void *ip_cls)
 List all of the identifiers in the namespace for which we could produce an update. More...
 

Detailed Description

publishing to namespaces, and tracking updateable entries for our namespaces

Author
Christian Grothoff

Definition in file fs_namespace.c.

Function Documentation

◆ get_update_information_directory()

static char * get_update_information_directory ( struct GNUNET_FS_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey ns 
)
static

Return the name of the directory in which we store the update information graph for the given local namespace.

Parameters
hfile-sharing handle
nsnamespace handle
Returns
NULL on error, otherwise the name of the directory

Definition at line 128 of file fs_namespace.c.

131{
132 char *dn;
133 char *ret;
135 struct GNUNET_HashCode hc;
137
138 if (GNUNET_OK !=
139 GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR", &dn))
140 {
142 return NULL;
143 }
145 GNUNET_CRYPTO_hash (&pub, sizeof(pub), &hc);
148 "%s%s%s",
149 dn,
151 (const char *) enc.encoding);
152 GNUNET_free (dn);
153 return ret;
154}
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static int ret
Final status code.
Definition: gnunet-arm.c:94
static OpusEncoder * enc
OPUS encoder.
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:187
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition: crypto_hash.c:55
@ GNUNET_OK
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_free(ptr)
Wrapper around free.
#define DIR_SEPARATOR_STR
Definition: platform.h:166
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
0-terminated ASCII encoding of a struct GNUNET_HashCode.
A 512-bit hashcode.

References GNUNET_ARM_Handle::cfg, DIR_SEPARATOR_STR, enc, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_to_enc(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_config_missing(), GNUNET_OK, h, ns, pub, and ret.

Referenced by read_update_information_graph(), and write_update_information_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_update_information_graph()

static void free_update_information_graph ( struct GNUNET_FS_UpdateInformationGraph uig)
static

Release memory occupied by UIG datastructure.

Parameters
uigdata structure to free

Definition at line 163 of file fs_namespace.c.

164{
165 unsigned int i;
166 struct NamespaceUpdateNode *nsn;
167
168 for (i = 0; i < uig->update_node_count; i++)
169 {
170 nsn = uig->update_nodes[i];
173 GNUNET_free (nsn->id);
174 GNUNET_free (nsn->update);
175 GNUNET_free (nsn);
176 }
178 if (NULL != uig->update_map)
180 GNUNET_free (uig);
181}
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
void GNUNET_FS_meta_data_destroy(struct GNUNET_FS_MetaData *md)
Free meta data.
Definition: meta_data.c:166
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:105
struct GNUNET_CONTAINER_MultiHashMap * update_map
Hash map mapping identifiers of update nodes to the update nodes (initialized on-demand).
Definition: fs_namespace.c:100
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:89
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:42
struct GNUNET_FS_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:56
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:61
char * update
Identifier of children of this node.
Definition: fs_namespace.c:51
char * id
Identifier for this node.
Definition: fs_namespace.c:46

References GNUNET_array_grow, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_uri_destroy(), NamespaceUpdateNode::id, NamespaceUpdateNode::md, NamespaceUpdateNode::update, GNUNET_FS_UpdateInformationGraph::update_map, GNUNET_FS_UpdateInformationGraph::update_node_count, GNUNET_FS_UpdateInformationGraph::update_nodes, and NamespaceUpdateNode::uri.

Referenced by GNUNET_FS_namespace_list_updateable(), and sks_publish_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_update_information_graph()

static void write_update_information_graph ( struct GNUNET_FS_UpdateInformationGraph uig)
static

Write a namespace's update node graph to a file.

Parameters
uigupdate information graph to dump

Definition at line 190 of file fs_namespace.c.

191{
192 char *fn;
193 struct GNUNET_BIO_WriteHandle *wh;
194 unsigned int i;
195 struct NamespaceUpdateNode *n;
196 char *uris;
197
198 fn = get_update_information_directory (uig->h, &uig->ns);
200 if (NULL == wh)
201 {
203 _ ("Failed to open `%s' for writing: %s\n"),
204 fn,
205 strerror (errno));
206 GNUNET_free (fn);
207 return;
208 }
210 "fs-namespace-node-count",
211 uig->update_node_count))
212 goto END;
213 for (i = 0; i < uig->update_node_count; i++)
214 {
215 n = uig->update_nodes[i];
216 uris = GNUNET_FS_uri_to_string (n->uri);
217 struct GNUNET_BIO_WriteSpec ws[] = {
218 GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id),
219 GNUNET_FS_write_spec_meta_data ("fs-namespace-node-meta", n->md),
220 GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update),
221 GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris),
223 };
225 {
226 GNUNET_free (uris);
227 break;
228 }
229 GNUNET_free (uris);
230 }
231 END:
232 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
234 _ ("Failed to write `%s': %s\n"),
235 fn,
236 strerror (errno));
237 GNUNET_free (fn);
238}
static char * get_update_information_directory(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
Return the name of the directory in which we store the update information graph for the given local n...
Definition: fs_namespace.c:128
@ END
We're done processing.
enum GNUNET_GenericReturnValue GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
Definition: bio.c:556
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
Definition: bio.c:508
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
Definition: bio.c:847
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_string(const char *what, const char *s)
Create the specification to write a 0-terminated string.
Definition: bio.c:1201
#define GNUNET_BIO_write_spec_end()
End of specifications marker.
enum GNUNET_GenericReturnValue GNUNET_BIO_write_spec_commit(struct GNUNET_BIO_WriteHandle *h, struct GNUNET_BIO_WriteSpec *ws)
Execute the write specifications in order.
Definition: bio.c:1359
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2034
struct GNUNET_BIO_WriteSpec GNUNET_FS_write_spec_meta_data(const char *what, const struct GNUNET_FS_MetaData *m)
Create the specification to write a metadata container.
Definition: meta_data.c:1223
#define GNUNET_log(kind,...)
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Handle for buffered writing.
Definition: bio.c:466
Structure specifying a writing operation on an IO handle.
GNUNET_BIO_WriteHandler wh
Function performing data serialization.
struct GNUNET_FS_Handle * h
Handle to the FS service context.
Definition: fs_namespace.c:84
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Private key for the namespace.
Definition: fs_namespace.c:94

References _, END, get_update_information_directory(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_open_file(), GNUNET_BIO_write_spec_commit(), GNUNET_BIO_write_spec_end, GNUNET_BIO_write_spec_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_uri_to_string(), GNUNET_FS_write_spec_meta_data(), GNUNET_log, GNUNET_OK, GNUNET_FS_UpdateInformationGraph::h, NamespaceUpdateNode::id, NamespaceUpdateNode::md, GNUNET_FS_UpdateInformationGraph::ns, NamespaceUpdateNode::update, GNUNET_FS_UpdateInformationGraph::update_node_count, GNUNET_FS_UpdateInformationGraph::update_nodes, NamespaceUpdateNode::uri, and GNUNET_BIO_WriteSpec::wh.

Referenced by sks_publish_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_update_information_graph()

static struct GNUNET_FS_UpdateInformationGraph * read_update_information_graph ( struct GNUNET_FS_Handle h,
const struct GNUNET_CRYPTO_EcdsaPrivateKey ns 
)
static

Read the namespace update node graph from a file.

Parameters
hFS handle to use
nsnamespace to read
Returns
update graph, never NULL

Definition at line 249 of file fs_namespace.c.

251{
253 char *fn;
254 struct GNUNET_BIO_ReadHandle *rh;
255 unsigned int i;
256 struct NamespaceUpdateNode *n;
257 char *uris;
258 uint32_t count;
259 char *emsg;
260
262 uig->h = h;
263 uig->ns = *ns;
266 {
267 GNUNET_free (fn);
268 return uig;
269 }
271 if (NULL == rh)
272 {
273 GNUNET_free (fn);
274 return uig;
275 }
276 if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "fs-namespace-count",
277 (int32_t *) &count))
278 {
279 GNUNET_break (0);
280 goto END;
281 }
282 if (count > 1024 * 1024)
283 {
284 GNUNET_break (0);
285 goto END;
286 }
287 if (0 == count)
288 goto END;
289 uig->update_nodes =
290 GNUNET_malloc (count * sizeof(struct NamespaceUpdateNode *));
291
292 for (i = 0; i < count; i++)
293 {
294 n = GNUNET_new (struct NamespaceUpdateNode);
295 struct GNUNET_BIO_ReadSpec rs[] = {
296 GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024),
297 GNUNET_FS_read_spec_meta_data ("meta", &n->md),
298 GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024),
299 GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2),
301 };
303 {
304 GNUNET_break (0);
305 GNUNET_free (n->id);
306 GNUNET_free (n->update);
307 if (n->md != NULL)
309 GNUNET_free (n);
310 break;
311 }
312 n->uri = GNUNET_FS_uri_parse (uris, &emsg);
313 GNUNET_free (uris);
314 if (n->uri == NULL)
315 {
316 GNUNET_break (0);
317 GNUNET_free (emsg);
318 GNUNET_free (n->id);
319 GNUNET_free (n->update);
321 GNUNET_free (n);
322 break;
323 }
324 uig->update_nodes[i] = n;
325 }
326 uig->update_node_count = i;
327 END:
328 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
329 {
331 _ ("Failed to read `%s': %s\n"),
332 fn,
333 emsg);
334 GNUNET_free (emsg);
335 }
336 GNUNET_free (fn);
337 return uig;
338}
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_string(const char *what, char **result, size_t max_length)
Create the specification to read a 0-terminated string.
Definition: bio.c:956
enum GNUNET_GenericReturnValue GNUNET_BIO_read_spec_commit(struct GNUNET_BIO_ReadHandle *h, struct GNUNET_BIO_ReadSpec *rs)
Execute the read specifications in order.
Definition: bio.c:1108
#define GNUNET_BIO_read_spec_end()
End of specifications marker.
enum GNUNET_GenericReturnValue GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open handle.
Definition: bio.c:162
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
Definition: bio.c:427
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open_file(const char *fn)
Open a file for reading.
Definition: bio.c:114
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
Definition: disk.c:482
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:637
struct GNUNET_BIO_ReadSpec GNUNET_FS_read_spec_meta_data(const char *what, struct GNUNET_FS_MetaData **result)
Create the specification to read a metadata container.
Definition: meta_data.c:1185
@ GNUNET_YES
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
Handle for buffered reading.
Definition: bio.c:69
Structure specifying a reading operation on an IO handle.
GNUNET_BIO_ReadHandler rh
Function performing data deserialization.
Handle to update information for a namespace.
Definition: fs_namespace.c:80

References _, END, get_update_information_directory(), GNUNET_BIO_read_close(), GNUNET_BIO_read_int32(), GNUNET_BIO_read_open_file(), GNUNET_BIO_read_spec_commit(), GNUNET_BIO_read_spec_end, GNUNET_BIO_read_spec_string(), GNUNET_break, GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_meta_data_destroy(), GNUNET_FS_read_spec_meta_data(), GNUNET_FS_uri_parse(), GNUNET_log, GNUNET_malloc, GNUNET_new, GNUNET_OK, GNUNET_YES, h, GNUNET_FS_UpdateInformationGraph::h, NamespaceUpdateNode::id, NamespaceUpdateNode::md, ns, GNUNET_FS_UpdateInformationGraph::ns, GNUNET_BIO_ReadSpec::rh, NamespaceUpdateNode::update, GNUNET_FS_UpdateInformationGraph::update_node_count, GNUNET_FS_UpdateInformationGraph::update_nodes, and NamespaceUpdateNode::uri.

Referenced by GNUNET_FS_namespace_list_updateable(), and sks_publish_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sks_publish_cont()

static void sks_publish_cont ( void *  cls,
const char *  msg 
)
static

Function called by the UBlock construction with the result from the PUT (UBlock) request.

Parameters
clsclosure of type "struct GNUNET_FS_PublishSksContext*"
msgerror message (or NULL)

Definition at line 397 of file fs_namespace.c.

398{
399 struct GNUNET_FS_PublishSksContext *psc = cls;
401
402 psc->uc = NULL;
403 if (NULL != msg)
404 {
405 if (NULL != psc->cont)
406 psc->cont (psc->cont_cls, NULL, msg);
408 return;
409 }
410 if (NULL != psc->nsn)
411 {
412 /* FIXME: this can be done much more
413 * efficiently by simply appending to the
414 * file and overwriting the 4-byte header */
415 uig = read_update_information_graph (psc->h, &psc->ns);
417 psc->nsn = NULL;
420 }
421 if (NULL != psc->cont)
422 psc->cont (psc->cont_cls, psc->uri, NULL);
424}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static void free_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Release memory occupied by UIG datastructure.
Definition: fs_namespace.c:163
static struct GNUNET_FS_UpdateInformationGraph * read_update_information_graph(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
Read the namespace update node graph from a file.
Definition: fs_namespace.c:249
static void write_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Write a namespace's update node graph to a file.
Definition: fs_namespace.c:190
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:491
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
Context for the SKS publication.
Definition: fs_namespace.c:345
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we're publishing to.
Definition: fs_namespace.c:360
GNUNET_FS_PublishContinuation cont
Function to call once we're done.
Definition: fs_namespace.c:375
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:380
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed).
Definition: fs_namespace.c:355
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:385
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:370
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:349

References GNUNET_FS_PublishSksContext::cont, GNUNET_FS_PublishSksContext::cont_cls, free_update_information_graph(), GNUNET_array_append, GNUNET_FS_publish_sks_cancel(), GNUNET_FS_PublishSksContext::h, msg, GNUNET_FS_PublishSksContext::ns, GNUNET_FS_PublishSksContext::nsn, read_update_information_graph(), GNUNET_FS_PublishSksContext::uc, GNUNET_FS_UpdateInformationGraph::update_node_count, GNUNET_FS_UpdateInformationGraph::update_nodes, GNUNET_FS_PublishSksContext::uri, and write_update_information_graph().

Referenced by GNUNET_FS_publish_sks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_update_node()

static int process_update_node ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Call the iterator in the closure for each node.

Parameters
clsclosure (of type 'struct ProcessUpdateClosure *')
keycurrent key code
valuevalue in the hash map (of type 'struct NamespaceUpdateNode *')
Returns
GNUNET_YES if we should continue to iterate, GNUNET_NO if not.

Definition at line 544 of file fs_namespace.c.

545{
546 struct ProcessUpdateClosure *pc = cls;
547 struct NamespaceUpdateNode *nsn = value;
548
549 pc->ip (pc->ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
550 return GNUNET_YES;
551}
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
Closure for 'process_update_node'.
Definition: fs_namespace.c:520

References GNUNET_YES, NamespaceUpdateNode::id, NamespaceUpdateNode::md, pc, NamespaceUpdateNode::update, NamespaceUpdateNode::uri, and value.

Referenced by GNUNET_FS_namespace_list_updateable().

Here is the caller graph for this function:

◆ find_trees()

static int find_trees ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Find all nodes reachable from the current node (including the current node itself).

If they are in no tree, add them to the current one. If they are the head of another tree, merge the trees. If they are in the middle of another tree, let them be. We can tell that a node is already in an tree by checking if its 'nug' field is set to the current 'nug' value. It is the head of an tree if it is in the 'tree_array' under its respective 'tree_id'.

In short, we're trying to find the smallest number of tree to cover a directed graph.

Parameters
clsclosure (of type 'struct FindTreeClosure')
keycurrent key code
valuevalue in the hash map
Returns
GNUNET_YES if we should continue to iterate, GNUNET_NO if not.

Definition at line 607 of file fs_namespace.c.

608{
609 struct FindTreeClosure *fc = cls;
610 struct NamespaceUpdateNode *nsn = value;
611 struct GNUNET_HashCode hc;
612
613 if (nsn->nug == fc->nug)
614 {
615 if (UINT_MAX == nsn->tree_id)
616 return GNUNET_YES; /* circular */
618 if (fc->tree_array[nsn->tree_id] != nsn)
619 return GNUNET_YES; /* part of "another" (directed) TREE,
620 * and not root of it, end trace */
621 if (nsn->tree_id == fc->id)
622 return GNUNET_YES; /* that's our own root (can this be?) */
623 /* merge existing TREE, we have a root for both */
624 fc->tree_array[nsn->tree_id] = NULL;
625 if (UINT_MAX == fc->id)
626 fc->id = nsn->tree_id; /* take over ID */
627 }
628 else
629 {
630 nsn->nug = fc->nug;
631 nsn->tree_id = UINT_MAX; /* mark as undef */
632 /* trace */
633 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
635 &hc,
636 &find_trees,
637 fc);
638 }
639 return GNUNET_YES;
640}
static int find_trees(void *cls, const struct GNUNET_HashCode *key, void *value)
Find all nodes reachable from the current node (including the current node itself).
Definition: fs_namespace.c:607
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Closure for 'find_trees'.
Definition: fs_namespace.c:558
unsigned int id
Identifier for the current TREE, or UINT_MAX for none yet.
Definition: fs_namespace.c:582
struct GNUNET_FS_UpdateInformationGraph * uig
UIG we are operating on.
Definition: fs_namespace.c:562
unsigned int tree_array_size
Size of 'tree_array'.
Definition: fs_namespace.c:572
struct NamespaceUpdateNode ** tree_array
Array with 'head's of TREEs.
Definition: fs_namespace.c:567
unsigned int nug
Current generational ID used.
Definition: fs_namespace.c:577
unsigned int tree_id
TREE this entry belongs to (if nug is current).
Definition: fs_namespace.c:72
unsigned int nug
Namespace update generation ID.
Definition: fs_namespace.c:67

References find_trees(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CRYPTO_hash(), GNUNET_YES, FindTreeClosure::id, NamespaceUpdateNode::nug, FindTreeClosure::nug, FindTreeClosure::tree_array, FindTreeClosure::tree_array_size, NamespaceUpdateNode::tree_id, FindTreeClosure::uig, NamespaceUpdateNode::update, GNUNET_FS_UpdateInformationGraph::update_map, and value.

Referenced by find_trees(), and GNUNET_FS_namespace_list_updateable().

Here is the call graph for this function:
Here is the caller graph for this function: