From 8c23a185ee8d3c16c5552668dced851f82986041 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 Apr 2011 13:47:56 +0000 Subject: changing datastore API to support replication level --- not fully implemented --- and adding GNUNET_FS_BlockOptions struct to replace prio/anonymity/expiration+replication args --- src/fs/fs.c | 30 +++---- src/fs/fs.h | 14 +-- src/fs/fs_file_information.c | 131 +++++++---------------------- src/fs/fs_namespace.c | 48 ++++------- src/fs/fs_publish.c | 82 ++++++------------ src/fs/fs_test_lib.c | 17 ++-- src/fs/gnunet-pseudonym.c | 25 +++--- src/fs/gnunet-publish.c | 39 +++------ src/fs/gnunet-service-fs.c | 10 ++- src/fs/gnunet-service-fs_new.c | 2 +- src/fs/gnunet-service-fs_pr.c | 2 + src/fs/gnunet-service-fs_push.c | 8 +- src/fs/test_fs_download.c | 9 +- src/fs/test_fs_download_indexed.c | 9 +- src/fs/test_fs_download_persistence.c | 9 +- src/fs/test_fs_file_information.c | 23 +++-- src/fs/test_fs_list_indexed.c | 19 +++-- src/fs/test_fs_namespace.c | 30 ++++--- src/fs/test_fs_namespace_list_updateable.c | 16 ++-- src/fs/test_fs_publish.c | 21 +++-- src/fs/test_fs_publish_persistence.c | 19 +++-- src/fs/test_fs_search.c | 9 +- src/fs/test_fs_search_persistence.c | 9 +- src/fs/test_fs_unindex.c | 9 +- src/fs/test_fs_unindex_persistence.c | 9 +- 25 files changed, 247 insertions(+), 352 deletions(-) (limited to 'src/fs') diff --git a/src/fs/fs.c b/src/fs/fs.c index 36eb3e5e1..81250b88c 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Christian Grothoff (and other contributing authors) + (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -768,8 +768,6 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) || (GNUNET_YES != GNUNET_FS_uri_test_chk (ret->chk_uri)) ) ) || - (GNUNET_OK != - GNUNET_BIO_read_int64 (rh, &ret->expirationTime.abs_value)) || (GNUNET_OK != read_start_time (rh, &ret->start_time)) || (GNUNET_OK != @@ -777,9 +775,13 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, (GNUNET_OK != GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16*1024)) || (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &ret->anonymity)) || + GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value)) || + (GNUNET_OK != + GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) || + (GNUNET_OK != + GNUNET_BIO_read_int32 (rh, &ret->bo.content_priority)) || (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &ret->priority)) ) + GNUNET_BIO_read_int32 (rh, &ret->bo.replication_level)) ) { GNUNET_break (0); goto cleanup; @@ -1180,8 +1182,6 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi) GNUNET_BIO_write_string (wh, ksks)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, chks)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, fi->expirationTime.abs_value)) || (GNUNET_OK != write_start_time (wh, fi->start_time)) || (GNUNET_OK != @@ -1189,9 +1189,13 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi) (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->filename)) || (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, fi->anonymity)) || + GNUNET_BIO_write_int64 (wh, fi->bo.expiration_time.abs_value)) || + (GNUNET_OK != + GNUNET_BIO_write_int32 (wh, fi->bo.anonymity_level)) || + (GNUNET_OK != + GNUNET_BIO_write_int32 (wh, fi->bo.content_priority)) || (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, fi->priority)) ) + GNUNET_BIO_write_int32 (wh, fi->bo.replication_level)) ) { GNUNET_break (0); goto cleanup; @@ -1340,10 +1344,8 @@ find_file_position (struct GNUNET_FS_FileInformation *pos, * @param length length of the file or directory * @param meta metadata for the file or directory (can be modified) * @param uri pointer to the keywords that will be used for this entry (can be modified) - * @param anonymity pointer to selected anonymity level (can be modified) - * @param priority pointer to selected priority (can be modified) + * @param bo block options (can be modified) * @param do_index should we index? - * @param expirationTime pointer to selected expiration time (can be modified) * @param client_info pointer to client context set upon creation (can be modified) * @return GNUNET_OK to continue (always) */ @@ -1353,10 +1355,8 @@ fip_signal_resume(void *cls, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, - uint32_t *anonymity, - uint32_t *priority, + struct GNUNET_FS_BlockOptions *bo, int *do_index, - struct GNUNET_TIME_Absolute *expirationTime, void **client_info) { struct GNUNET_FS_PublishContext *sc = cls; diff --git a/src/fs/fs.h b/src/fs/fs.h index ff769cfca..2040d035a 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -438,9 +438,9 @@ struct GNUNET_FS_FileInformation struct GNUNET_FS_Uri *chk_uri; /** - * At what time should the content expire? + * Block options for the file. */ - struct GNUNET_TIME_Absolute expirationTime; + struct GNUNET_FS_BlockOptions bo; /** * At what time did we start this upload? @@ -547,16 +547,6 @@ struct GNUNET_FS_FileInformation } data; - /** - * Desired anonymity level. - */ - uint32_t anonymity; - - /** - * Desired priority (for keeping the content in the DB). - */ - uint32_t priority; - /** * Is this struct for a file or directory? */ diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index 2ae708e59..b248fae44 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009 Christian Grothoff (and other contributing authors) + (C) 2009, 2011 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -132,11 +132,7 @@ GNUNET_FS_file_information_get_id (struct GNUNET_FS_FileInformation *s) * @param meta metadata for the file * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, * GNUNET_SYSERR for simulation - * @param anonymity what is the desired anonymity level for sharing? - * @param priority what is the priority for OUR node to - * keep this file available? Use 0 for maximum anonymity and - * minimum reliability... - * @param expirationTime when should this content expire? + * @param bo block options * @return publish structure entry for the file */ struct GNUNET_FS_FileInformation * @@ -146,9 +142,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_CONTAINER_MetaData *meta, int do_index, - uint32_t anonymity, - uint32_t priority, - struct GNUNET_TIME_Absolute expirationTime) + const struct GNUNET_FS_BlockOptions *bo) { struct FileInfo *fi; struct stat sbuf; @@ -177,9 +171,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, keywords, meta, do_index, - anonymity, - priority, - expirationTime); + bo); if (ret == NULL) return NULL; ret->h = h; @@ -212,11 +204,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, * @param meta metadata for the file * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, * GNUNET_SYSERR for simulation - * @param anonymity what is the desired anonymity level for sharing? - * @param priority what is the priority for OUR node to - * keep this file available? Use 0 for maximum anonymity and - * minimum reliability... - * @param expirationTime when should this content expire? + * @param bo block options * @return publish structure entry for the file */ struct GNUNET_FS_FileInformation * @@ -227,9 +215,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_CONTAINER_MetaData *meta, int do_index, - uint32_t anonymity, - uint32_t priority, - struct GNUNET_TIME_Absolute expirationTime) + const struct GNUNET_FS_BlockOptions *bo) { if (GNUNET_YES == do_index) { @@ -244,9 +230,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, keywords, meta, do_index, - anonymity, - priority, - expirationTime); + bo); } @@ -263,11 +247,7 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, * @param meta metadata for the file * @param do_index GNUNET_YES for index, GNUNET_NO for insertion, * GNUNET_SYSERR for simulation - * @param anonymity what is the desired anonymity level for sharing? - * @param priority what is the priority for OUR node to - * keep this file available? Use 0 for maximum anonymity and - * minimum reliability... - * @param expirationTime when should this content expire? + * @param bo block options * @return publish structure entry for the file */ struct GNUNET_FS_FileInformation * @@ -279,9 +259,7 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_CONTAINER_MetaData *meta, int do_index, - uint32_t anonymity, - uint32_t priority, - struct GNUNET_TIME_Absolute expirationTime) + const struct GNUNET_FS_BlockOptions *bo) { struct GNUNET_FS_FileInformation *ret; @@ -298,13 +276,11 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h, if (ret->meta == NULL) ret->meta = GNUNET_CONTAINER_meta_data_create (); ret->keywords = (keywords == NULL) ? NULL : GNUNET_FS_uri_dup (keywords); - ret->expirationTime = expirationTime; ret->data.file.reader = reader; ret->data.file.reader_cls = reader_cls; ret->data.file.do_index = do_index; ret->data.file.file_size = length; - ret->anonymity = anonymity; - ret->priority = priority; + ret->bo = *bo; return ret; } @@ -350,24 +326,15 @@ struct DirScanCls char *emsg; /** - * Should files be indexed? - */ - int do_index; - - /** - * Desired anonymity level. + * Block options. */ - uint32_t anonymity; + const struct GNUNET_FS_BlockOptions *bo; /** - * Desired publishing priority. - */ - uint32_t priority; + * Should files be indexed? + */ + int do_index; - /** - * Expiration time for publication. - */ - struct GNUNET_TIME_Absolute expiration; }; @@ -406,9 +373,7 @@ dir_scan_cb (void *cls, dsc->scanner, dsc->scanner_cls, dsc->do_index, - dsc->anonymity, - dsc->priority, - dsc->expiration, + dsc->bo, &dsc->emsg); if (NULL == fi) { @@ -430,9 +395,7 @@ dir_scan_cb (void *cls, ksk_uri, meta, dsc->do_index, - dsc->anonymity, - dsc->priority, - dsc->expiration); + dsc->bo); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_FS_uri_destroy (keywords); GNUNET_FS_uri_destroy (ksk_uri); @@ -459,9 +422,7 @@ dir_scan_cb (void *cls, * @param h handle to the file sharing subsystem * @param dirname name of the directory to scan * @param do_index should files be indexed or inserted - * @param anonymity desired anonymity level - * @param priority priority for publishing - * @param expirationTime expiration for publication + * @param bo block options * @param proc function called on each entry * @param proc_cls closure for proc * @param emsg where to store an error message (on errors) @@ -472,9 +433,7 @@ GNUNET_FS_directory_scanner_default (void *cls, struct GNUNET_FS_Handle *h, const char *dirname, int do_index, - uint32_t anonymity, - uint32_t priority, - struct GNUNET_TIME_Absolute expirationTime, + const struct GNUNET_FS_BlockOptions *bo, GNUNET_FS_FileProcessor proc, void *proc_cls, char **emsg) @@ -489,9 +448,7 @@ GNUNET_FS_directory_scanner_default (void *cls, dsc.scanner = &GNUNET_FS_directory_scanner_default; dsc.scanner_cls = cls; dsc.do_index = do_index; - dsc.anonymity = anonymity; - dsc.priority = priority; - dsc.expiration = expirationTime; + dsc.bo = bo; if (-1 == GNUNET_DISK_directory_scan (dirname, &dir_scan_cb, &dsc)) @@ -555,11 +512,7 @@ dirproc (void *cls, * @param scanner function used to get a list of files in a directory * @param scanner_cls closure for scanner * @param do_index should files in the hierarchy be indexed? - * @param anonymity what is the desired anonymity level for sharing? - * @param priority what is the priority for OUR node to - * keep this file available? Use 0 for maximum anonymity and - * minimum reliability... - * @param expirationTime when should this content expire? + * @param bo block options * @param emsg where to store an error message * @return publish structure entry for the directory, NULL on error */ @@ -570,9 +523,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, GNUNET_FS_DirectoryScanner scanner, void *scanner_cls, int do_index, - uint32_t anonymity, - uint32_t priority, - struct GNUNET_TIME_Absolute expirationTime, + const struct GNUNET_FS_BlockOptions *bo, char **emsg) { struct GNUNET_FS_FileInformation *ret; @@ -590,9 +541,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, h, filename, do_index, - anonymity, - priority, - expirationTime, + bo, &dirproc, &dc, emsg); @@ -602,9 +551,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, client_info, ksk, meta, - anonymity, - priority, - expirationTime); + bo); GNUNET_CONTAINER_meta_data_destroy (meta); ret->data.dir.entries = dc.entries; while (dc.entries != NULL) @@ -657,11 +604,7 @@ GNUNET_FS_file_information_is_directory (struct GNUNET_FS_FileInformation *ent) * @param meta metadata for the directory * @param keywords under which keywords should this directory be available * directly; can be NULL - * @param anonymity what is the desired anonymity level for sharing? - * @param priority what is the priority for OUR node to - * keep this file available? Use 0 for maximum anonymity and - * minimum reliability... - * @param expirationTime when should this content expire? + * @param bo block options * @return publish structure entry for the directory , NULL on error */ struct GNUNET_FS_FileInformation * @@ -669,9 +612,7 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, void *client_info, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_CONTAINER_MetaData *meta, - uint32_t anonymity, - uint32_t priority, - struct GNUNET_TIME_Absolute expirationTime) + const struct GNUNET_FS_BlockOptions *bo) { struct GNUNET_FS_FileInformation *ret; @@ -680,10 +621,8 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, ret->client_info = client_info; ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); ret->keywords = GNUNET_FS_uri_dup (keywords); - ret->expirationTime = expirationTime; + ret->bo = *bo; ret->is_directory = GNUNET_YES; - ret->anonymity = anonymity; - ret->priority = priority; return ret; } @@ -747,10 +686,8 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir, (dir->is_directory) ? dir->data.dir.dir_size : dir->data.file.file_size, dir->meta, &dir->keywords, - &dir->anonymity, - &dir->priority, + &dir->bo, (dir->is_directory) ? &no : &dir->data.file.do_index, - &dir->expirationTime, &dir->client_info)) return; if (! dir->is_directory) @@ -765,10 +702,8 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir, (pos->is_directory) ? pos->data.dir.dir_size : pos->data.file.file_size, pos->meta, &pos->keywords, - &pos->anonymity, - &pos->priority, + &pos->bo, (dir->is_directory) ? &no : &dir->data.file.do_index, - &pos->expirationTime, &pos->client_info)) break; pos = pos->next; @@ -810,10 +745,8 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, fi->data.dir.dir_size, fi->meta, &fi->keywords, - &fi->anonymity, - &fi->priority, + &fi->bo, &no, - &fi->expirationTime, &fi->client_info); GNUNET_free_non_null (fi->data.dir.dir_data); } @@ -830,10 +763,8 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, fi->data.file.file_size, fi->meta, &fi->keywords, - &fi->anonymity, - &fi->priority, + &fi->bo, &fi->data.file.do_index, - &fi->expirationTime, &fi->client_info); } GNUNET_free_non_null (fi->filename); diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index bc66bb21f..175879707 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c @@ -285,25 +285,15 @@ struct AdvertisementContext struct GNUNET_FS_Namespace *ns; /** - * Expiration time. + * Block options. */ - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_FS_BlockOptions bo; /** * Number of bytes of plaintext. */ size_t pt_size; - /** - * Anonymity level. - */ - uint32_t anonymity; - - /** - * Content priority. - */ - uint32_t priority; - /** * Current keyword offset. */ @@ -410,9 +400,10 @@ advertisement_cont (void *cls, ac->pt_size + sizeof (struct NBlock), ac->nb, GNUNET_BLOCK_TYPE_FS_NBLOCK, - ac->priority, - ac->anonymity, - ac->expiration, + ac->bo.content_priority, + ac->bo.anonymity_level, + ac->bo.replication_level, + ac->bo.expiration_time, -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &advertisement_cont, @@ -427,9 +418,7 @@ advertisement_cont (void *cls, * @param ksk_uri keywords to use for advertisment * @param namespace handle for the namespace that should be advertised * @param meta meta-data for the namespace advertisement - * @param anonymity for the namespace advertismement - * @param priority for the namespace advertisement - * @param expiration for the namespace advertisement + * @param bo block options * @param rootEntry name of the root of the namespace * @param cont continuation * @param cont_cls closure for cont @@ -439,9 +428,7 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, struct GNUNET_FS_Uri *ksk_uri, struct GNUNET_FS_Namespace *namespace, const struct GNUNET_CONTAINER_MetaData *meta, - uint32_t anonymity, - uint32_t priority, - struct GNUNET_TIME_Absolute expiration, + const struct GNUNET_FS_BlockOptions *bo, const char *rootEntry, GNUNET_FS_PublishContinuation cont, void *cont_cls) @@ -512,9 +499,7 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, ctx->pt_size = mdsize + reslen; ctx->ns = namespace; ctx->ns->rc++; - ctx->anonymity = anonymity; - ctx->priority = priority; - ctx->expiration = expiration; + ctx->bo = *bo; advertisement_cont (ctx, GNUNET_OK, NULL); } @@ -828,9 +813,7 @@ sb_put_cont (void *cls, * @param update update identifier to use * @param meta metadata to use * @param uri URI to refer to in the SBlock - * @param expirationTime when the SBlock expires - * @param anonymity anonymity level for the SBlock - * @param priority priority for the SBlock + * @param bo block options * @param options publication options * @param cont continuation * @param cont_cls closure for cont @@ -842,9 +825,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, const char *update, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, - struct GNUNET_TIME_Absolute expirationTime, - uint32_t anonymity, - uint32_t priority, + const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls) @@ -975,9 +956,10 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, size, sb_enc, GNUNET_BLOCK_TYPE_FS_SBLOCK, - priority, - anonymity, - expirationTime, + bo->content_priority, + bo->anonymity_level, + bo->replication_level, + bo->expiration_time, -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &sb_put_cont, diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index ac69c94a1..36efb27f6 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -95,7 +95,7 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, pi->value.publish.size); pi->value.publish.completed = offset; pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time); - pi->value.publish.anonymity = p->anonymity; + pi->value.publish.anonymity = p->bo.anonymity_level; return sc->h->upcb (sc->h->upcb_cls, pi); } @@ -324,9 +324,7 @@ publish_sblock (struct GNUNET_FS_PublishContext *sc) sc->nuid, sc->fi->meta, sc->fi->chk_uri, - sc->fi->expirationTime, - sc->fi->anonymity, - sc->fi->priority, + &sc->fi->bo, sc->options, &publish_sblocks_cont, sc); @@ -569,9 +567,10 @@ block_proc (void *cls, sizeof (struct OnDemandBlock), &odb, GNUNET_BLOCK_TYPE_FS_ONDEMAND, - p->priority, - p->anonymity, - p->expirationTime, + p->bo.content_priority, + p->bo.anonymity_level, + p->bo.replication_level, + p->bo.expiration_time, -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont, @@ -591,9 +590,10 @@ block_proc (void *cls, block_size, block, type, - p->priority, - p->anonymity, - p->expirationTime, + p->bo.content_priority, + p->bo.anonymity_level, + p->bo.replication_level, + p->bo.expiration_time, -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont, @@ -990,12 +990,12 @@ GNUNET_FS_publish_main_ (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "File upload complete, now publishing KSK blocks.\n"); #endif - if (0 == p->anonymity) + if (0 == p->bo.anonymity_level) { /* zero anonymity, box CHK URI in LOC URI */ loc = GNUNET_FS_uri_loc_create (p->chk_uri, pc->h->cfg, - p->expirationTime); + p->bo.expiration_time); GNUNET_FS_uri_destroy (p->chk_uri); p->chk_uri = loc; } @@ -1007,9 +1007,7 @@ GNUNET_FS_publish_main_ (void *cls, p->keywords, p->meta, p->chk_uri, - p->expirationTime, - p->anonymity, - p->priority, + &p->bo, pc->options, &publish_kblocks_cont, pc); @@ -1065,10 +1063,8 @@ GNUNET_FS_publish_main_ (void *cls, * @param length length of the file or directory * @param meta metadata for the file or directory (can be modified) * @param uri pointer to the keywords that will be used for this entry (can be modified) - * @param anonymity pointer to selected anonymity level (can be modified) - * @param priority pointer to selected priority (can be modified) + * @param bo block options * @param do_index should we index? - * @param expirationTime pointer to selected expiration time (can be modified) * @param client_info pointer to client context set upon creation (can be modified) * @return GNUNET_OK to continue (always) */ @@ -1078,10 +1074,8 @@ fip_signal_start(void *cls, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, - uint32_t *anonymity, - uint32_t *priority, + struct GNUNET_FS_BlockOptions *bo, int *do_index, - struct GNUNET_TIME_Absolute *expirationTime, void **client_info) { struct GNUNET_FS_PublishContext *sc = cls; @@ -1134,10 +1128,8 @@ fip_signal_start(void *cls, * @param length length of the file or directory * @param meta metadata for the file or directory (can be modified) * @param uri pointer to the keywords that will be used for this entry (can be modified) - * @param anonymity pointer to selected anonymity level (can be modified) - * @param priority pointer to selected priority (can be modified) + * @param bo block options * @param do_index should we index? - * @param expirationTime pointer to selected expiration time (can be modified) * @param client_info pointer to client context set upon creation (can be modified) * @return GNUNET_OK to continue (always) */ @@ -1147,10 +1139,8 @@ fip_signal_suspend(void *cls, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, - uint32_t *anonymity, - uint32_t *priority, + struct GNUNET_FS_BlockOptions *bo, int *do_index, - struct GNUNET_TIME_Absolute *expirationTime, void **client_info) { struct GNUNET_FS_PublishContext*sc = cls; @@ -1322,10 +1312,8 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, * @param length length of the file or directory * @param meta metadata for the file or directory (can be modified) * @param uri pointer to the keywords that will be used for this entry (can be modified) - * @param anonymity pointer to selected anonymity level (can be modified) - * @param priority pointer to selected priority (can be modified) + * @param bo block options (can be modified) * @param do_index should we index? - * @param expirationTime pointer to selected expiration time (can be modified) * @param client_info pointer to client context set upon creation (can be modified) * @return GNUNET_OK to continue (always) */ @@ -1335,10 +1323,8 @@ fip_signal_stop(void *cls, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, - uint32_t *anonymity, - uint32_t *priority, + struct GNUNET_FS_BlockOptions *bo, int *do_index, - struct GNUNET_TIME_Absolute *expirationTime, void **client_info) { struct GNUNET_FS_PublishContext*sc = cls; @@ -1454,7 +1440,7 @@ struct PublishKskContext /** * When should the KBlocks expire? */ - struct GNUNET_TIME_Absolute expirationTime; + struct GNUNET_FS_BlockOptions bo; /** * Size of the serialized metadata. @@ -1471,15 +1457,6 @@ struct PublishKskContext */ unsigned int i; - /** - * Anonymity level for the KBlocks. - */ - uint32_t anonymity; - - /** - * Priority for the KBlocks. - */ - uint32_t priority; }; @@ -1604,9 +1581,10 @@ publish_ksk_cont (void *cls, pkc->slen, pkc->cpy, GNUNET_BLOCK_TYPE_FS_KBLOCK, - pkc->priority, - pkc->anonymity, - pkc->expirationTime, + pkc->bo.content_priority, + pkc->bo.anonymity_level, + pkc->bo.replication_level, + pkc->bo.expiration_time, -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &kb_put_cont, @@ -1621,9 +1599,7 @@ publish_ksk_cont (void *cls, * @param ksk_uri keywords to use * @param meta metadata to use * @param uri URI to refer to in the KBlock - * @param expirationTime when the KBlock expires - * @param anonymity anonymity level for the KBlock - * @param priority priority for the KBlock + * @param bo per-block options * @param options publication options * @param cont continuation * @param cont_cls closure for cont @@ -1633,9 +1609,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *ksk_uri, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, - struct GNUNET_TIME_Absolute expirationTime, - uint32_t anonymity, - uint32_t priority, + const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls) @@ -1649,9 +1623,7 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, GNUNET_assert (NULL != uri); pkc = GNUNET_malloc (sizeof (struct PublishKskContext)); pkc->h = h; - pkc->expirationTime = expirationTime; - pkc->anonymity = anonymity; - pkc->priority = priority; + pkc->bo = *bo; pkc->cont = cont; pkc->cont_cls = cont_cls; if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 4af4dae33..c379d91ad 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2010 Christian Grothoff (and other contributing authors) + (C) 2010, 2011 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -637,12 +637,17 @@ GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, uint64_t off; char buf[DBLOCK_SIZE]; size_t bsize; - + struct GNUNET_FS_BlockOptions bo; + GNUNET_assert (daemon->publish_cont == NULL); daemon->publish_cont = cont; daemon->publish_cont_cls = cont_cls; daemon->publish_seed = seed; daemon->verbose = verbose; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (CONTENT_LIFETIME); + bo.anonymity_level = anonymity; + bo.content_priority = 42; + bo.replication_level = 1; if (GNUNET_YES == do_index) { GNUNET_assert (daemon->publish_tmp_file == NULL); @@ -678,9 +683,7 @@ GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, daemon->publish_tmp_file, NULL, NULL, do_index, - anonymity, - 42 /* priority */, - GNUNET_TIME_relative_to_absolute (CONTENT_LIFETIME)); + &bo); } else { @@ -692,9 +695,7 @@ GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, NULL, NULL, do_index, - anonymity, - 42 /* priority */, - GNUNET_TIME_relative_to_absolute (CONTENT_LIFETIME)); + &bo); } daemon->publish_context = GNUNET_FS_publish_start (daemon->fs, fi, diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c index b7aba8ef4..769b4239d 100644 --- a/src/fs/gnunet-pseudonym.c +++ b/src/fs/gnunet-pseudonym.c @@ -25,11 +25,6 @@ #include "platform.h" #include "gnunet_fs_service.h" -/** - * -a optiton. - */ -static unsigned int anonymity; - /** * -C option */ @@ -56,9 +51,9 @@ static int print_local_only; static struct GNUNET_CONTAINER_MetaData *adv_metadata; /** - * -p option. + * Our block options (-p, -r, -a). */ -static unsigned int priority = 365; +static struct GNUNET_FS_BlockOptions bo = { { 2 * 365 * 24 * 60 * 60 * 1000LL }, 1, 365, 1 }; /** * -q option given. @@ -279,9 +274,7 @@ run (void *cls, ksk_uri, ns, adv_metadata, - anonymity, - priority, - expiration, + &bo, root_identifier, &post_advertising, NULL); @@ -307,7 +300,8 @@ run (void *cls, /** - * The main function to inspect GNUnet directories. + * The main function to manipulate GNUnet pseudonyms (and publish + * to namespaces). * * @param argc number of arguments from the command line * @param argv command line arguments @@ -319,7 +313,7 @@ main (int argc, char *const *argv) static const struct GNUNET_GETOPT_CommandLineOption options[] = { {'a', "anonymity", "LEVEL", gettext_noop ("set the desired LEVEL of sender-anonymity"), - 1, &GNUNET_GETOPT_set_uint, &anonymity}, + 1, &GNUNET_GETOPT_set_uint, &bo.anonymity_level}, {'C', "create", "NAME", gettext_noop ("create or advertise namespace NAME"), @@ -341,11 +335,14 @@ main (int argc, char *const *argv) 0, &GNUNET_GETOPT_set_one, &print_local_only}, {'p', "priority", "PRIORITY", gettext_noop ("use the given PRIORITY for the advertisments"), - 1, &GNUNET_GETOPT_set_uint, &priority}, + 1, &GNUNET_GETOPT_set_uint, &bo.content_priority}, {'q', "quiet", NULL, gettext_noop ("do not print names of remote namespaces"), 0, &GNUNET_GETOPT_set_one, &no_remote_printing}, - {'r', "root", "ID", + {'r', "replication", "LEVEL", + gettext_noop ("set the desired replication LEVEL"), + 0, &GNUNET_GETOPT_set_uint, &bo.replication_level}, + {'R', "root", "ID", gettext_noop ("specify ID of the root of the namespace"), 1, &GNUNET_GETOPT_set_string, &root_identifier}, diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 2021a9816..1fbdb9e07 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2010 Christian Grothoff (and other contributing authors) + (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2010, 2011 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -28,8 +28,6 @@ #include "platform.h" #include "gnunet_fs_service.h" -#define DEFAULT_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 2) - static int ret; static int verbose; @@ -46,9 +44,7 @@ static struct GNUNET_FS_Uri *topKeywords; static struct GNUNET_FS_Uri *uri; -static unsigned int anonymity = 1; - -static unsigned int priority = 365; +static struct GNUNET_FS_BlockOptions bo = { { 2 * 365 * 24 * 60 * 60 * 1000LL }, 1, 365, 1 }; static char *uri_string; @@ -240,10 +236,8 @@ keyword_printer (void *cls, * @param length length of the file or directory * @param m metadata for the file or directory (can be modified) * @param uri pointer to the keywords that will be used for this entry (can be modified) - * @param anonymity pointer to selected anonymity level (can be modified) - * @param priority pointer to selected priority (can be modified) + * @param bo block options * @param do_index should we index? - * @param expirationTime pointer to selected expiration time (can be modified) * @param client_info pointer to client context set upon creation (can be modified) * @return GNUNET_OK to continue, GNUNET_NO to remove * this entry from the directory, GNUNET_SYSERR @@ -255,10 +249,8 @@ publish_inspector (void *cls, uint64_t length, struct GNUNET_CONTAINER_MetaData *m, struct GNUNET_FS_Uri **uri, - unsigned int *anonymity, - unsigned int *priority, + struct GNUNET_FS_BlockOptions *bo, int *do_index, - struct GNUNET_TIME_Absolute *expirationTime, void **client_info) { char *fn; @@ -375,9 +367,7 @@ uri_ksk_continuation (void *cls, next_id, meta, uri, - GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION), - anonymity, - priority, + &bo, GNUNET_FS_PUBLISH_OPTION_NONE, uri_sks_continuation, NULL); @@ -517,9 +507,7 @@ run (void *cls, topKeywords, meta, uri, - GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION), - anonymity, - priority, + &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &uri_ksk_continuation, NULL); @@ -557,9 +545,7 @@ run (void *cls, &GNUNET_FS_directory_scanner_default, plugins, !do_insert, - anonymity, - priority, - GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION), + &bo, &emsg); } else @@ -576,9 +562,7 @@ run (void *cls, keywords, NULL, !do_insert, - anonymity, - priority, - GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION)); + &bo); GNUNET_break (fi != NULL); GNUNET_FS_uri_destroy (keywords); } @@ -644,7 +628,7 @@ main (int argc, char *const *argv) static const struct GNUNET_GETOPT_CommandLineOption options[] = { {'a', "anonymity", "LEVEL", gettext_noop ("set the desired LEVEL of sender-anonymity"), - 1, &GNUNET_GETOPT_set_uint, &anonymity}, + 1, &GNUNET_GETOPT_set_uint, &bo.anonymity_level}, {'d', "disable-creation-time", NULL, gettext_noop ("disable adding the creation time to the metadata of the uploaded file"), @@ -676,11 +660,14 @@ main (int argc, char *const *argv) 1, &GNUNET_GETOPT_set_string, &next_id}, {'p', "priority", "PRIORITY", gettext_noop ("specify the priority of the content"), - 1, &GNUNET_GETOPT_set_uint, &priority}, + 1, &GNUNET_GETOPT_set_uint, &bo.content_priority}, {'P', "pseudonym", "NAME", gettext_noop ("publish the files under the pseudonym NAME (place file into namespace)"), 1, &GNUNET_GETOPT_set_string, &pseudonym}, + {'r', "replication", "LEVEL", + gettext_noop ("set the desired replication LEVEL"), + 0, &GNUNET_GETOPT_set_uint, &bo.replication_level}, {'s', "simulate-only", NULL, gettext_noop ("only simulate the process but do not do any " "actual publishing (useful to compute URIs)"), diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 74a88e7b2..caf534140 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -1432,9 +1432,9 @@ gather_migration_blocks (void *cls, mig_task = GNUNET_SCHEDULER_NO_TASK; if (dsh != NULL) { - mig_qe = GNUNET_DATASTORE_get_random (dsh, 0, UINT_MAX, - GNUNET_TIME_UNIT_FOREVER_REL, - &process_migration_content, NULL); + mig_qe = GNUNET_DATASTORE_get_for_replication (dsh, 0, UINT_MAX, + GNUNET_TIME_UNIT_FOREVER_REL, + &process_migration_content, NULL); GNUNET_assert (mig_qe != NULL); } } @@ -3764,8 +3764,10 @@ handle_p2p_put (void *cls, GNUNET_DATASTORE_put (dsh, 0, &query, dsize, &put[1], type, prq.priority, 1 /* anonymity */, + 0 /* replication */, expiration, - 1 + prq.priority, MAX_DATASTORE_QUEUE, + 1 + prq.priority, + MAX_DATASTORE_QUEUE, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &put_migration_continuation, start); diff --git a/src/fs/gnunet-service-fs_new.c b/src/fs/gnunet-service-fs_new.c index acfb95600..20a98e6f2 100644 --- a/src/fs/gnunet-service-fs_new.c +++ b/src/fs/gnunet-service-fs_new.c @@ -523,7 +523,7 @@ main_init (struct GNUNET_SERVER_Handle *server, }; GSF_core = GNUNET_CORE_connect (GSF_cfg, - 1, /* larger? */ + 2, /* larger? */ NULL, &peer_init_handler, &peer_connect_handler, diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index f6b31c4e2..c44a658df 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -915,6 +915,7 @@ handle_dht_reply (void *cls, GNUNET_DATASTORE_put (GSF_dsh, 0, key, size, data, type, prq.priority, 1 /* anonymity */, + 0 /* replication */, exp, 1 + prq.priority, MAX_DATASTORE_QUEUE, GNUNET_CONSTANTS_SERVICE_TIMEOUT, @@ -1237,6 +1238,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, GNUNET_DATASTORE_put (GSF_dsh, 0, &query, dsize, &put[1], type, prq.priority, 1 /* anonymity */, + 0 /* replication */, expiration, 1 + prq.priority, MAX_DATASTORE_QUEUE, GNUNET_CONSTANTS_SERVICE_TIMEOUT, diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c index 38d916832..094489273 100644 --- a/src/fs/gnunet-service-fs_push.c +++ b/src/fs/gnunet-service-fs_push.c @@ -576,10 +576,10 @@ gather_migration_blocks (void *cls, return; if (GSF_dsh != NULL) { - mig_qe = GNUNET_DATASTORE_get_random (GSF_dsh, - 0, UINT_MAX, - GNUNET_TIME_UNIT_FOREVER_REL, - &process_migration_content, NULL); + mig_qe = GNUNET_DATASTORE_get_for_replication (GSF_dsh, + 0, UINT_MAX, + GNUNET_TIME_UNIT_FOREVER_REL, + &process_migration_content, NULL); GNUNET_assert (mig_qe != NULL); } } diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 5091c5a61..35592225a 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -295,6 +295,7 @@ run (void *cls, struct GNUNET_FS_Uri *kuri; struct GNUNET_FS_FileInformation *fi; size_t i; + struct GNUNET_FS_BlockOptions bo; setup_peer (&p1, "test_fs_download_data.conf"); fs = GNUNET_FS_start (cfg, @@ -309,6 +310,10 @@ run (void *cls, buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", FILESIZE, @@ -316,9 +321,7 @@ run (void *cls, kuri, meta, GNUNET_NO, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c index 33ca42a16..afb544f51 100644 --- a/src/fs/test_fs_download_indexed.c +++ b/src/fs/test_fs_download_indexed.c @@ -294,6 +294,7 @@ run (void *cls, struct GNUNET_CONTAINER_MetaData *meta; struct GNUNET_FS_Uri *kuri; struct GNUNET_FS_FileInformation *fi; + struct GNUNET_FS_BlockOptions bo; size_t i; setup_peer (&p1, "test_fs_download_data.conf"); @@ -317,15 +318,17 @@ run (void *cls, GNUNET_free (buf); meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn1, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index 0ea7a5524..035cbb55e 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c @@ -359,6 +359,7 @@ run (void *cls, struct GNUNET_FS_Uri *kuri; struct GNUNET_FS_FileInformation *fi; size_t i; + struct GNUNET_FS_BlockOptions bo; cfg = c; setup_peer (&p1, "test_fs_download_data.conf"); @@ -374,6 +375,10 @@ run (void *cls, buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", FILESIZE, @@ -381,9 +386,7 @@ run (void *cls, kuri, meta, GNUNET_NO, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c index 914dbad9f..00e3c2211 100644 --- a/src/fs/test_fs_file_information.c +++ b/src/fs/test_fs_file_information.c @@ -55,10 +55,8 @@ mycleaner(void *cls, uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, - uint32_t *anonymity, - uint32_t *priority, + struct GNUNET_FS_BlockOptions *bo, int *do_index, - struct GNUNET_TIME_Absolute *expirationTime, void **client_info) { return GNUNET_OK; @@ -85,6 +83,7 @@ run (void *cls, struct GNUNET_FS_FileInformation *fidir; struct GNUNET_FS_Handle *fs; size_t i; + struct GNUNET_FS_BlockOptions bo; fs = GNUNET_FS_start (cfg, "test-fs-file-information", NULL, NULL, GNUNET_FS_FLAGS_NONE, @@ -112,16 +111,18 @@ run (void *cls, GNUNET_free (buf); meta = GNUNET_CONTAINER_meta_data_create (); - kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi1 = GNUNET_FS_file_information_create_from_file (fs, "file_information-context1", fn1, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (fi1 != NULL); fi2 = GNUNET_FS_file_information_create_from_file (fs, "file_information-context2", @@ -129,17 +130,13 @@ run (void *cls, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (fi2 != NULL); fidir = GNUNET_FS_file_information_create_empty_directory (fs, "file_information-context-dir", kuri, meta, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index ec3d6fecd..d53732eaf 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c @@ -239,6 +239,7 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi2; struct GNUNET_FS_FileInformation *fidir; size_t i; + struct GNUNET_FS_BlockOptions bo; setup_peer (&p1, "test_fs_list_indexed_data.conf"); fs = GNUNET_FS_start (cfg, @@ -272,33 +273,33 @@ run (void *cls, meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi1 = GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context1", fn1, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (NULL != fi1); + bo.anonymity_level = 2; fi2 = GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context2", fn2, kuri, meta, GNUNET_YES, - 2, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (NULL != fi2); + bo.anonymity_level = 3; fidir = GNUNET_FS_file_information_create_empty_directory (fs, "list_indexed-context-dir", kuri, meta, - 3, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index 11b6ef8c2..02bb62807 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c @@ -275,22 +275,24 @@ sks_cont (void *cls, const char *emsg) { struct GNUNET_CONTAINER_MetaData *meta; - struct GNUNET_TIME_Absolute expiration; struct GNUNET_FS_Uri *ksk_uri; char * msg; + struct GNUNET_FS_BlockOptions bo; - expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); meta = GNUNET_CONTAINER_meta_data_create (); msg = NULL; ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/ns-search", &msg); GNUNET_assert (NULL == msg); ksk_expect_uri = GNUNET_FS_uri_dup (uri); + bo.content_priority = 1; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); GNUNET_FS_publish_ksk (fs, ksk_uri, meta, uri, - expiration, - 1, 1, + &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &publish_cont, NULL); @@ -306,7 +308,7 @@ adv_cont (void *cls, { struct GNUNET_CONTAINER_MetaData *meta; struct GNUNET_FS_Namespace *ns; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_FS_BlockOptions bo; if (NULL != emsg) { @@ -315,21 +317,23 @@ adv_cont (void *cls, GNUNET_FS_stop (fs); return; } - expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); ns = GNUNET_FS_namespace_create (fs, "testNamespace"); GNUNET_assert (NULL != ns); meta = GNUNET_CONTAINER_meta_data_create (); GNUNET_assert (NULL == emsg); sks_expect_uri = GNUNET_FS_uri_dup (uri); + bo.content_priority = 1; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri, /* FIXME: this is non-sense (use CHK URI!?) */ - expiration, - 1, 1, + &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont, NULL); @@ -357,7 +361,7 @@ static void testNamespace () { struct GNUNET_FS_Namespace *ns; - struct GNUNET_TIME_Absolute expiration; + struct GNUNET_FS_BlockOptions bo; struct GNUNET_CONTAINER_MetaData *meta; struct GNUNET_FS_Uri *ksk_uri; int ok; @@ -375,15 +379,17 @@ testNamespace () err = 1; return; } - expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); meta = GNUNET_CONTAINER_meta_data_create (); ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/testnsa", NULL); + bo.content_priority = 1; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); GNUNET_FS_namespace_advertise (fs, ksk_uri, ns, meta, - 1, 1, - expiration, + &bo, "root", &adv_cont, NULL); kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c index 359800f56..dda7bb4f2 100644 --- a/src/fs/test_fs_namespace_list_updateable.c +++ b/src/fs/test_fs_namespace_list_updateable.c @@ -40,14 +40,14 @@ static int err; static struct GNUNET_FS_Namespace *ns; -static struct GNUNET_TIME_Absolute expiration; - static struct GNUNET_CONTAINER_MetaData *meta; static struct GNUNET_FS_Uri *uri_this; static struct GNUNET_FS_Uri *uri_next; +static struct GNUNET_FS_BlockOptions bo; + struct PeerContext { @@ -172,6 +172,7 @@ sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) { + GNUNET_assert (NULL == emsg); err = 1; GNUNET_FS_namespace_list_updateable (ns, @@ -184,8 +185,7 @@ sks_cont_this (void *cls, "future", meta, uri_next, - expiration, - 1, 1, + &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL); @@ -201,7 +201,10 @@ testNamespace () ns = GNUNET_FS_namespace_create (fs, "testNamespace"); GNUNET_assert (NULL != ns); - expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); + bo.content_priority = 1; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); meta = GNUNET_CONTAINER_meta_data_create (); uri_this = @@ -214,8 +217,7 @@ testNamespace () "next", meta, uri_this, - expiration, - 1, 1, + &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_this, NULL); diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index 99d4b6710..b206fb415 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c @@ -225,6 +225,7 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi2; struct GNUNET_FS_FileInformation *fidir; size_t i; + struct GNUNET_FS_BlockOptions bo; setup_peer (&p1, "test_fs_publish_data.conf"); fs = GNUNET_FS_start (cfg, @@ -258,33 +259,35 @@ run (void *cls, meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); + fi1 = GNUNET_FS_file_information_create_from_file (fs, "publish-context1", fn1, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); + GNUNET_assert (NULL != fi1); + bo.anonymity_level = 2; fi2 = GNUNET_FS_file_information_create_from_file (fs, "publish-context2", fn2, kuri, meta, GNUNET_YES, - 2, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (NULL != fi2); + bo.anonymity_level = 3; fidir = GNUNET_FS_file_information_create_empty_directory (fs, "publish-context-dir", kuri, meta, - 3, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index 4a84bf9dc..1610c25c1 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c @@ -282,6 +282,7 @@ run (void *cls, struct GNUNET_FS_FileInformation *fi2; struct GNUNET_FS_FileInformation *fidir; size_t i; + struct GNUNET_FS_BlockOptions bo; cfg = c; setup_peer (&p1, "test_fs_publish_data.conf"); @@ -316,33 +317,33 @@ run (void *cls, meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi1 = GNUNET_FS_file_information_create_from_file (fs, "publish-context1", fn1, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (NULL != fi1); + bo.anonymity_level = 2; fi2 = GNUNET_FS_file_information_create_from_file (fs, "publish-context2", fn2, kuri, meta, GNUNET_YES, - 2, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (NULL != fi2); + bo.anonymity_level = 3; fidir = GNUNET_FS_file_information_create_empty_directory (fs, "publish-context-dir", kuri, meta, - 3, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c index 2544b8a6e..0c44cb612 100644 --- a/src/fs/test_fs_search.c +++ b/src/fs/test_fs_search.c @@ -226,6 +226,7 @@ run (void *cls, char *buf; struct GNUNET_CONTAINER_MetaData *meta; struct GNUNET_FS_Uri *kuri; + struct GNUNET_FS_BlockOptions bo; struct GNUNET_FS_FileInformation *fi; size_t i; @@ -242,6 +243,10 @@ run (void *cls, buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", FILESIZE, @@ -249,9 +254,7 @@ run (void *cls, kuri, meta, GNUNET_NO, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c index e2a213cd8..f04dad9f3 100644 --- a/src/fs/test_fs_search_persistence.c +++ b/src/fs/test_fs_search_persistence.c @@ -297,6 +297,7 @@ run (void *cls, struct GNUNET_FS_Uri *kuri; struct GNUNET_FS_FileInformation *fi; size_t i; + struct GNUNET_FS_BlockOptions bo; cfg = c; setup_peer (&p1, "test_fs_search_data.conf"); @@ -312,6 +313,10 @@ run (void *cls, buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", FILESIZE, @@ -319,9 +324,7 @@ run (void *cls, kuri, meta, GNUNET_NO, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index 82d4cdcf7..99611a6c8 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c @@ -233,6 +233,7 @@ run (void *cls, struct GNUNET_FS_Uri *kuri; struct GNUNET_FS_FileInformation *fi; size_t i; + struct GNUNET_FS_BlockOptions bo; setup_peer (&p1, "test_fs_unindex_data.conf"); fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); @@ -254,15 +255,17 @@ run (void *cls, GNUNET_free (buf); meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index 162dd59af..ee4a4c2db 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c @@ -301,6 +301,7 @@ run (void *cls, struct GNUNET_FS_Uri *kuri; struct GNUNET_FS_FileInformation *fi; size_t i; + struct GNUNET_FS_BlockOptions bo; cfg = c; setup_peer (&p1, "test_fs_unindex_data.conf"); @@ -323,15 +324,17 @@ run (void *cls, GNUNET_free (buf); meta = GNUNET_CONTAINER_meta_data_create (); kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); + bo.content_priority = 42; + bo.anonymity_level = 1; + bo.replication_level = 0; + bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn, kuri, meta, GNUNET_YES, - 1, - 42, - GNUNET_TIME_relative_to_absolute (LIFETIME)); + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); -- cgit v1.2.3