GNUnet  0.10.x
Data Structures | Functions
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_CONTAINER_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 129 of file fs_namespace.c.

References GNUNET_FS_Handle::cfg, DIR_SEPARATOR_STR, GNUNET_CRYPTO_HashAsciiEncoded::encoding, 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, and ret.

Referenced by read_update_information_graph(), and write_update_information_graph().

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",
140  &dn))
141  {
143  "fs", "UPDATE_DIR");
144  return NULL;
145  }
147  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &hc);
149  &enc);
150  GNUNET_asprintf (&ret, "%s%s%s",
151  dn,
153  (const char *) enc.encoding);
154  GNUNET_free (dn);
155  return ret;
156 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static int ret
Final status code.
Definition: gnunet-arm.c:89
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
A 512-bit hashcode.
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:69
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:241
0-terminated ASCII encoding of a struct GNUNET_HashCode.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:39
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static OpusEncoder * enc
OPUS encoder.
int 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.
#define DIR_SEPARATOR_STR
Definition: plibc.h:632
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1092
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 165 of file fs_namespace.c.

References GNUNET_array_grow, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_free, 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().

166 {
167  unsigned int i;
168  struct NamespaceUpdateNode *nsn;
169 
170  for (i = 0; i < uig->update_node_count; i++)
171  {
172  nsn = uig->update_nodes[i];
174  GNUNET_FS_uri_destroy (nsn->uri);
175  GNUNET_free (nsn->id);
176  GNUNET_free (nsn->update);
177  GNUNET_free (nsn);
178  }
180  0);
181  if (NULL != uig->update_map)
183  GNUNET_free (uig);
184 }
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
char * id
Identifier for this node.
Definition: fs_namespace.c:45
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:106
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:670
struct GNUNET_CONTAINER_MultiHashMap * update_map
Hash map mapping identifiers of update nodes to the update nodes (initialized on-demand).
Definition: fs_namespace.c:101
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:90
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
#define GNUNET_free(ptr)
Wrapper around free.
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 193 of file fs_namespace.c.

References _, END, fn, get_update_information_directory(), GNUNET_BIO_write_close(), GNUNET_BIO_write_int32(), GNUNET_BIO_write_meta_data(), GNUNET_BIO_write_open(), GNUNET_BIO_write_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_FS_uri_to_string(), GNUNET_log, GNUNET_OK, GNUNET_FS_UpdateInformationGraph::h, NamespaceUpdateNode::id, NamespaceUpdateNode::md, GNUNET_FS_UpdateInformationGraph::ns, STRERROR, NamespaceUpdateNode::update, GNUNET_FS_UpdateInformationGraph::update_node_count, GNUNET_FS_UpdateInformationGraph::update_nodes, NamespaceUpdateNode::uri, and wh.

Referenced by sks_publish_cont().

194 {
195  char *fn;
196  struct GNUNET_BIO_WriteHandle *wh;
197  unsigned int i;
198  struct NamespaceUpdateNode *n;
199  char *uris;
200 
202  &uig->ns);
203  wh = GNUNET_BIO_write_open (fn);
204  if (NULL == wh)
205  {
207  _("Failed to open `%s' for writing: %s\n"),
208  fn,
209  STRERROR (errno));
210  GNUNET_free (fn);
211  return;
212  }
214  goto END;
215  for (i = 0; i < uig->update_node_count; i++)
216  {
217  n = uig->update_nodes[i];
218  uris = GNUNET_FS_uri_to_string (n->uri);
219  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, n->id)) ||
220  (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, n->md)) ||
221  (GNUNET_OK != GNUNET_BIO_write_string (wh, n->update)) ||
222  (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)))
223  {
224  GNUNET_free (uris);
225  break;
226  }
227  GNUNET_free (uris);
228  }
229 END:
230  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
232  _("Failed to write `%s': %s\n"),
233  fn,
234  STRERROR (errno));
235  GNUNET_free (fn);
236 }
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m)
Write metadata container to a file.
Definition: bio.c:569
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:547
struct GNUNET_FS_Handle * h
Handle to the FS service context.
Definition: fs_namespace.c:85
#define STRERROR(i)
Definition: plibc.h:676
We&#39;re done processing.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:1988
char * id
Identifier for this node.
Definition: fs_namespace.c:45
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:106
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Private key for the namespace.
Definition: fs_namespace.c:95
static char * fn
Filename of the unique file.
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
Handle for buffered writing.
Definition: bio.c:399
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:90
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:457
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:129
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open(const char *fn)
Open a file for writing.
Definition: bio.c:430
#define GNUNET_log(kind,...)
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:605
#define GNUNET_free(ptr)
Wrapper around free.
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 247 of file fs_namespace.c.

References _, END, fn, get_update_information_directory(), GNUNET_BIO_read_close(), GNUNET_BIO_read_int32, GNUNET_BIO_read_meta_data(), GNUNET_BIO_read_open(), GNUNET_BIO_read_string(), GNUNET_break, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_free_non_null, GNUNET_FS_uri_parse(), GNUNET_log, GNUNET_malloc, GNUNET_new, GNUNET_OK, GNUNET_YES, GNUNET_FS_UpdateInformationGraph::h, h, NamespaceUpdateNode::id, NamespaceUpdateNode::md, ns, GNUNET_FS_UpdateInformationGraph::ns, 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().

249 {
251  char *fn;
252  struct GNUNET_BIO_ReadHandle *rh;
253  unsigned int i;
254  struct NamespaceUpdateNode *n;
255  char *uris;
256  uint32_t count;
257  char *emsg;
258 
260  uig->h = h;
261  uig->ns = *ns;
263  if (GNUNET_YES != GNUNET_DISK_file_test (fn))
264  {
265  GNUNET_free (fn);
266  return uig;
267  }
268  rh = GNUNET_BIO_read_open (fn);
269  if (NULL == rh)
270  {
271  GNUNET_free (fn);
272  return uig;
273  }
274  if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &count))
275  {
276  GNUNET_break (0);
277  goto END;
278  }
279  if (count > 1024 * 1024)
280  {
281  GNUNET_break (0);
282  goto END;
283  }
284  if (0 == count)
285  goto END;
286  uig->update_nodes =
287  GNUNET_malloc (count * sizeof (struct NamespaceUpdateNode *));
288 
289  for (i = 0; i < count; i++)
290  {
291  n = GNUNET_new (struct NamespaceUpdateNode);
292  if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024))
293  || (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) ||
294  (GNUNET_OK !=
295  GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) ||
296  (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2)))
297  {
298  GNUNET_break (0);
301  if (n->md != NULL)
303  GNUNET_free (n);
304  break;
305  }
306  n->uri = GNUNET_FS_uri_parse (uris, &emsg);
307  GNUNET_free (uris);
308  if (n->uri == NULL)
309  {
310  GNUNET_break (0);
311  GNUNET_free (emsg);
312  GNUNET_free (n->id);
315  GNUNET_free (n);
316  break;
317  }
318  uig->update_nodes[i] = n;
319  }
320  uig->update_node_count = i;
321  END:
322  if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
323  {
324  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to read `%s': %s\n"),
325  fn, emsg);
326  GNUNET_free (emsg);
327  }
328  GNUNET_free (fn);
329  return uig;
330 }
int 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:669
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
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:635
struct GNUNET_FS_Handle * h
Handle to the FS service context.
Definition: fs_namespace.c:85
We&#39;re done processing.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open file.
Definition: bio.c:119
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open(const char *fn)
Open a file for reading.
Definition: bio.c:94
char * id
Identifier for this node.
Definition: fs_namespace.c:45
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:106
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Private key for the namespace.
Definition: fs_namespace.c:95
static char * fn
Filename of the unique file.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
int GNUNET_BIO_read_string(struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
Read 0-terminated string from a file.
Definition: bio.c:237
#define GNUNET_BIO_read_int32(h, i)
Read an (u)int32_t.
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:90
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:129
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
#define GNUNET_log(kind,...)
int GNUNET_BIO_read_meta_data(struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result)
Read metadata container from a file.
Definition: bio.c:286
#define GNUNET_YES
Definition: gnunet_common.h:80
Handle to update information for a namespace.
Definition: fs_namespace.c:79
#define GNUNET_malloc(size)
Wrapper around malloc.
Handle for buffered reading.
Definition: bio.c:53
#define GNUNET_free(ptr)
Wrapper around free.
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 390 of file fs_namespace.c.

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, 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().

392 {
393  struct GNUNET_FS_PublishSksContext *psc = cls;
395 
396  psc->uc = NULL;
397  if (NULL != msg)
398  {
399  if (NULL != psc->cont)
400  psc->cont (psc->cont_cls, NULL, msg);
402  return;
403  }
404  if (NULL != psc->nsn)
405  {
406  /* FIXME: this can be done much more
407  * efficiently by simply appending to the
408  * file and overwriting the 4-byte header */
409  uig = read_update_information_graph (psc->h,
410  &psc->ns);
412  uig->update_node_count,
413  psc->nsn);
414  psc->nsn = NULL;
417  }
418  if (NULL != psc->cont)
419  psc->cont (psc->cont_cls, psc->uri, NULL);
421 }
GNUNET_FS_PublishContinuation cont
Function to call once we&#39;re done.
Definition: fs_namespace.c:368
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:342
Context for the SKS publication.
Definition: fs_namespace.c:336
static void write_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Write a namespace&#39;s update node graph to a file.
Definition: fs_namespace.c:193
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:363
static void free_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Release memory occupied by UIG datastructure.
Definition: fs_namespace.c:165
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:106
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we&#39;re publishing to.
Definition: fs_namespace.c:353
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:503
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:90
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed)...
Definition: fs_namespace.c:348
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:373
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:247
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:378
Handle to update information for a namespace.
Definition: fs_namespace.c:79
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 556 of file fs_namespace.c.

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

Referenced by GNUNET_FS_namespace_list_updateable().

559 {
560  struct ProcessUpdateClosure *pc = cls;
561  struct NamespaceUpdateNode *nsn = value;
562 
563  pc->ip (pc->ip_cls,
564  nsn->id,
565  nsn->uri,
566  nsn->md,
567  nsn->update);
568  return GNUNET_YES;
569 }
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
GNUNET_FS_IdentifierProcessor ip
Function to call for each node.
Definition: fs_namespace.c:536
char * id
Identifier for this node.
Definition: fs_namespace.c:45
static char * value
Value of the record to add/remove.
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
Closure for &#39;process_update_node&#39;.
Definition: fs_namespace.c:531
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
void * ip_cls
Closure for &#39;ip&#39;.
Definition: fs_namespace.c:541
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
#define GNUNET_YES
Definition: gnunet_common.h:80
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 625 of file fs_namespace.c.

References 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 GNUNET_FS_namespace_list_updateable().

628 {
629  struct FindTreeClosure *fc = cls;
630  struct NamespaceUpdateNode *nsn = value;
631  struct GNUNET_HashCode hc;
632 
633  if (nsn->nug == fc->nug)
634  {
635  if (UINT_MAX == nsn->tree_id)
636  return GNUNET_YES; /* circular */
638  if (fc->tree_array[nsn->tree_id] != nsn)
639  return GNUNET_YES; /* part of "another" (directed) TREE,
640  * and not root of it, end trace */
641  if (nsn->tree_id == fc->id)
642  return GNUNET_YES; /* that's our own root (can this be?) */
643  /* merge existing TREE, we have a root for both */
644  fc->tree_array[nsn->tree_id] = NULL;
645  if (UINT_MAX == fc->id)
646  fc->id = nsn->tree_id; /* take over ID */
647  }
648  else
649  {
650  nsn->nug = fc->nug;
651  nsn->tree_id = UINT_MAX; /* mark as undef */
652  /* trace */
653  GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
655  &find_trees, fc);
656  }
657  return GNUNET_YES;
658 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int nug
Namespace update generation ID.
Definition: fs_namespace.c:66
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:625
Closure for &#39;find_trees&#39;.
Definition: fs_namespace.c:575
static char * value
Value of the record to add/remove.
unsigned int tree_array_size
Size of &#39;tree_array&#39;.
Definition: fs_namespace.c:590
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
unsigned int tree_id
TREE this entry belongs to (if nug is current).
Definition: fs_namespace.c:71
A 512-bit hashcode.
struct GNUNET_CONTAINER_MultiHashMap * update_map
Hash map mapping identifiers of update nodes to the update nodes (initialized on-demand).
Definition: fs_namespace.c:101
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
unsigned int nug
Current generational ID used.
Definition: fs_namespace.c:595
unsigned int id
Identifier for the current TREE, or UINT_MAX for none yet.
Definition: fs_namespace.c:600
struct GNUNET_FS_UpdateInformationGraph * uig
UIG we are operating on.
Definition: fs_namespace.c:580
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
struct NamespaceUpdateNode ** tree_array
Array with &#39;head&#39;s of TREEs.
Definition: fs_namespace.c:585
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function: