summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/defaults.conf2
-rw-r--r--doc/man/gnunet-pseudonym.16
-rw-r--r--doc/man/gnunet-publish.14
-rw-r--r--src/datastore/datastore_api.c20
-rw-r--r--src/datastore/perf_datastore_api.c12
-rw-r--r--src/datastore/test_datastore_api.c5
-rw-r--r--src/datastore/test_datastore_api_management.c3
-rw-r--r--src/fs/fs.c30
-rw-r--r--src/fs/fs.h14
-rw-r--r--src/fs/fs_file_information.c131
-rw-r--r--src/fs/fs_namespace.c48
-rw-r--r--src/fs/fs_publish.c82
-rw-r--r--src/fs/fs_test_lib.c17
-rw-r--r--src/fs/gnunet-pseudonym.c25
-rw-r--r--src/fs/gnunet-publish.c39
-rw-r--r--src/fs/gnunet-service-fs.c10
-rw-r--r--src/fs/gnunet-service-fs_new.c2
-rw-r--r--src/fs/gnunet-service-fs_pr.c2
-rw-r--r--src/fs/gnunet-service-fs_push.c8
-rw-r--r--src/fs/test_fs_download.c9
-rw-r--r--src/fs/test_fs_download_indexed.c9
-rw-r--r--src/fs/test_fs_download_persistence.c9
-rw-r--r--src/fs/test_fs_file_information.c23
-rw-r--r--src/fs/test_fs_list_indexed.c19
-rw-r--r--src/fs/test_fs_namespace.c30
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c16
-rw-r--r--src/fs/test_fs_publish.c21
-rw-r--r--src/fs/test_fs_publish_persistence.c19
-rw-r--r--src/fs/test_fs_search.c9
-rw-r--r--src/fs/test_fs_search_persistence.c9
-rw-r--r--src/fs/test_fs_unindex.c9
-rw-r--r--src/fs/test_fs_unindex_persistence.c9
-rw-r--r--src/include/gnunet_datastore_service.h26
-rw-r--r--src/include/gnunet_fs_service.h146
34 files changed, 368 insertions, 455 deletions
diff --git a/contrib/defaults.conf b/contrib/defaults.conf
index f0ee4e3e0..fe98f1d18 100644
--- a/contrib/defaults.conf
+++ b/contrib/defaults.conf
@@ -295,7 +295,7 @@ PORT = 2094
HOSTNAME = localhost
HOME = $SERVICEHOME
CONFIG = $DEFAULTCONFIG
-BINARY = gnunet-service-fs
+BINARY = gnunet-service-fs-new
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
diff --git a/doc/man/gnunet-pseudonym.1 b/doc/man/gnunet-pseudonym.1
index 30e7c4145..5d3c41b62 100644
--- a/doc/man/gnunet-pseudonym.1
+++ b/doc/man/gnunet-pseudonym.1
@@ -55,7 +55,11 @@ Set the priority of the namespace advertisement (default: 365). If the local da
Do not print the list of pseudonyms (only perform create or delete operation).
.TP
-\fB\-r IDENTIFIER\fR, \fB\-\-root=IDENTIFIER\fR
+\fB\-r \fILEVEL\fR, \fB\-\-replication=\fILEVEL\fR
+Set the desired replication level. If CONTENT_PUSHING is set to YES, GNUnet will push each block (for the file) LEVEL times to other peers before doing nomral "random" replication of all content. This option can be used to push some content out into the network harder. Note that pushing content LEVEL times into the network does not guarantee that there will actually be LEVEL replicas.
+
+.TP
+\fB\-R IDENTIFIER\fR, \fB\-\-root=IDENTIFIER\fR
Specify the identifier for the root of the namespace. Used in the namespace advertisement to tell users that find the namespace advertisement about an entry\-point into the namespace (use with \-C). Advertisements are only created if "\-C" and "\-r" are specified.
.TP
diff --git a/doc/man/gnunet-publish.1 b/doc/man/gnunet-publish.1
index df2059629..22bd4ae74 100644
--- a/doc/man/gnunet-publish.1
+++ b/doc/man/gnunet-publish.1
@@ -78,6 +78,10 @@ Set the priority of the published content (default: 365). If the local database
For the top\-level directory or file, create an SBlock that places the file into the namespace specified by the pseudonym NAME.
.TP
+\fB\-r \fILEVEL\fR, \fB\-\-replication=\fILEVEL\fR
+Set the desired replication level. If CONTENT_PUSHING is set to YES, GNUnet will push each block (for the file) LEVEL times to other peers before doing nomral "random" replication of all content. This option can be used to push some content out into the network harder. Note that pushing content LEVEL times into the network does not guarantee that there will actually be LEVEL replicas.
+
+.TP
\fB\-s\fR, \fB\-\-simulate-only\fR
When this option is used, gnunet\-publish will not actually publish the file but just simulate what would be done. This can be used to compute the GNUnet URI for a file without actually sharing it.
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index cf6a2cc8e..344a70842 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -792,6 +792,7 @@ process_status_message (void *cls,
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication how often should the content be replicated to other peers?
* @param expiration expiration time for the content
* @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped
@@ -812,6 +813,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
unsigned int queue_priority,
unsigned int max_queue_size,
@@ -1274,7 +1276,11 @@ process_result_message (void *cls,
/**
- * Get a random value from the datastore.
+ * Get a random value from the datastore for content replication.
+ * Returns a single, random value among those with the highest
+ * replication score, lowering positive replication scores by one for
+ * the chosen value (if only content with a replication score exists,
+ * a random value is returned and replication scores are not changed).
*
* @param h handle to the datastore
* @param queue_priority ranking of this request in the priority queue
@@ -1290,12 +1296,12 @@ process_result_message (void *cls,
* (or rather, will already have been invoked)
*/
struct GNUNET_DATASTORE_QueueEntry *
-GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
- unsigned int queue_priority,
- unsigned int max_queue_size,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_DATASTORE_Iterator iter,
- void *iter_cls)
+GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h,
+ unsigned int queue_priority,
+ unsigned int max_queue_size,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls)
{
struct GNUNET_DATASTORE_QueueEntry *qe;
struct GNUNET_MessageHeader *m;
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index de9a8b236..00d91b4c7 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -269,7 +269,7 @@ run_continuation (void *cls,
data,
i+1,
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100),
- i,
+ i, 0,
GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000))),
@@ -279,10 +279,10 @@ run_continuation (void *cls,
break;
case RP_CUT:
/* trim down below MAX_SIZE again */
- GNUNET_DATASTORE_get_random (datastore,
- 1, 1, TIMEOUT,
- &delete_value,
- crc);
+ GNUNET_DATASTORE_get_for_replication (datastore,
+ 1, 1, TIMEOUT,
+ &delete_value,
+ crc);
break;
case RP_REPORT:
printf (
@@ -355,7 +355,7 @@ run (void *cls,
GNUNET_DATASTORE_put (datastore, 0,
&zkey, 4, "TEST",
GNUNET_BLOCK_TYPE_TEST,
- 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
+ 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
0, 1, GNUNET_TIME_UNIT_MINUTES,
&run_tests, crc))
{
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index d8e4b7b34..965f05687 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -402,6 +402,7 @@ run_continuation (void *cls,
get_type (crc->i),
get_priority (crc->i),
get_anonymity (crc->i),
+ 0,
get_expiration (crc->i),
1, 1, TIMEOUT,
&check_success,
@@ -502,6 +503,7 @@ run_continuation (void *cls,
get_type (42),
get_priority (42),
get_anonymity (42),
+ 0,
get_expiration (42),
1, 1, TIMEOUT,
&check_success,
@@ -517,6 +519,7 @@ run_continuation (void *cls,
get_type (42),
get_priority (43),
get_anonymity (43),
+ 0,
get_expiration (43),
1, 1, TIMEOUT,
&check_success,
@@ -613,7 +616,7 @@ run (void *cls,
GNUNET_DATASTORE_put (datastore, 0,
&zkey, 4, "TEST",
GNUNET_BLOCK_TYPE_TEST,
- 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
+ 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
0, 1, GNUNET_TIME_UNIT_MINUTES,
&run_tests, crc))
{
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 2873caa02..50a426af6 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -231,6 +231,7 @@ run_continuation (void *cls,
get_type (crc->i),
get_priority (crc->i),
get_anonymity (crc->i),
+ 0,
get_expiration (crc->i),
1, 1, TIMEOUT,
&check_success,
@@ -327,7 +328,7 @@ run (void *cls,
GNUNET_DATASTORE_put (datastore, 0,
&zkey, 4, "TEST",
GNUNET_BLOCK_TYPE_TEST,
- 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
+ 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS),
0, 1, GNUNET_TIME_UNIT_MINUTES,
&run_tests, crc))
{
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
@@ -769,17 +769,19 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h,
(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 !=
GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16*1024)) ||
(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;
@@ -1181,17 +1183,19 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi)
(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 !=
GNUNET_BIO_write_string (wh, fi->emsg)) ||
(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?
@@ -548,16 +548,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?
*/
int is_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,9 +285,9 @@ 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.
@@ -295,16 +295,6 @@ struct AdvertisementContext
size_t pt_size;
/**
- * Anonymity level.
- */
- uint32_t anonymity;
-
- /**
- * Content priority.
- */
- uint32_t priority;
-
- /**
* Current keyword offset.
*/
unsigned int pos;
@@ -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
@@ -26,11 +26,6 @@
#include "gnunet_fs_service.h"
/**
- * -a optiton.
- */
-static unsigned int anonymity;
-
-/**
* -C option
*/
static char *create_ns;
@@ -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);
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h
index e9cb8a76f..1e2e9e050 100644
--- a/src/include/gnunet_datastore_service.h
+++ b/src/include/gnunet_datastore_service.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2004, 2005, 2006, 2007, 2009, 2010 Christian Grothoff (and other contributing authors)
+ (C) 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
@@ -122,8 +122,8 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h,
/**
* Store an item in the datastore. If the item is already present,
- * the priorities are summed up and the higher expiration time and
- * lower anonymity level is used.
+ * the priorities and replication values are summed up and the higher
+ * expiration time and lower anonymity level is used.
*
* @param h handle to the datastore
* @param rid reservation ID to use (from "reserve"); use 0 if no
@@ -134,6 +134,7 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h,
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication how often should the content be replicated to other peers?
* @param expiration expiration time for the content
* @param queue_priority ranking of this request in the priority queue
* @param max_queue_size at what queue size should this request be dropped
@@ -154,6 +155,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
unsigned int queue_priority,
unsigned int max_queue_size,
@@ -323,7 +325,11 @@ GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h);
/**
- * Get a random value from the datastore.
+ * Get a random value from the datastore for content replication.
+ * Returns a single, random value among those with the highest
+ * replication score, lowering positive replication scores by one for
+ * the chosen value (if only content with a replication score exists,
+ * a random value is returned and replication scores are not changed).
*
* @param h handle to the datastore
* @param queue_priority ranking of this request in the priority queue
@@ -339,12 +345,12 @@ GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h);
* (or rather, will already have been invoked)
*/
struct GNUNET_DATASTORE_QueueEntry *
-GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h,
- unsigned int queue_priority,
- unsigned int max_queue_size,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_DATASTORE_Iterator iter,
- void *iter_cls);
+GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h,
+ unsigned int queue_priority,
+ unsigned int max_queue_size,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_DATASTORE_Iterator iter,
+ void *iter_cls);
/**
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index 52cd8bd78..8238083b1 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -1574,6 +1574,52 @@ enum GNUNET_FS_OPTIONS
/**
+ * Settings for publishing a block (which may of course also
+ * apply to an entire directory or file).
+ */
+struct GNUNET_FS_BlockOptions
+{
+
+ /**
+ * At what time should the block expire? Data blocks (DBLOCKS and
+ * IBLOCKS) may still be used even if they are expired (however,
+ * they'd be removed quickly from the datastore if we are short on
+ * space), all other types of blocks will no longer be returned
+ * after they expire.
+ */
+ struct GNUNET_TIME_Absolute expiration_time;
+
+ /**
+ * At which anonymity level should the block be shared?
+ * (0: no anonymity, 1: normal GAP, >1: with cover traffic).
+ */
+ uint32_t anonymity_level;
+
+ /**
+ * How important is it for us to store the block? If we run
+ * out of space, the highest-priority, non-expired blocks will
+ * be kept.
+ */
+ uint32_t content_priority;
+
+ /**
+ * How often should we try to migrate the block to other peers?
+ * Only used if "CONTENT_PUSHING" is set to YES, in which case we
+ * first push each block to other peers according to their
+ * replication levels. Once each block has been pushed that many
+ * times to other peers, blocks are chosen for migration at random.
+ * Naturally, there is no guarantee that the other peers will keep
+ * these blocks for any period of time (since they won't have any
+ * priority or might be too busy to even store the block in the
+ * first place).
+ */
+ uint32_t replication_level;
+
+};
+
+
+
+/**
* Handle to the file-sharing service.
*/
struct GNUNET_FS_Handle;
@@ -1635,10 +1681,8 @@ GNUNET_FS_meta_data_extract_from_file (struct
* @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 (can be modified)
- * @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
@@ -1649,10 +1693,8 @@ typedef int (*GNUNET_FS_FileInformationProcessor)(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);
@@ -1682,11 +1724,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 *
@@ -1696,9 +1734,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);
/**
@@ -1714,11 +1750,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 *
@@ -1729,9 +1761,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);
/**
@@ -1770,11 +1800,7 @@ typedef size_t (*GNUNET_FS_DataReader)(void *cls,
* @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 *
@@ -1786,9 +1812,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);
/**
@@ -1813,9 +1837,7 @@ typedef void (*GNUNET_FS_FileProcessor)(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 to call on each entry
* @param proc_cls closure for proc
* @param emsg where to store an error message (on errors)
@@ -1825,9 +1847,7 @@ typedef int (*GNUNET_FS_DirectoryScanner)(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);
@@ -1849,9 +1869,7 @@ typedef int (*GNUNET_FS_DirectoryScanner)(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)
@@ -1862,9 +1880,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);
@@ -1886,11 +1902,7 @@ GNUNET_FS_directory_scanner_default (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
*/
@@ -1901,9 +1913,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);
@@ -1918,11 +1928,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
* @param keywords under which keywords should this directory be available
* directly; can be NULL
* @param meta metadata for the directory
- * @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 *
@@ -1930,9 +1936,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);
/**
@@ -2069,9 +2073,8 @@ typedef void (*GNUNET_FS_PublishContinuation)(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 block options
+ * @param options publication options
* @param cont continuation
* @param cont_cls closure for cont
*/
@@ -2080,9 +2083,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);
@@ -2097,9 +2098,8 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
* @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
*/
@@ -2110,9 +2110,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);
@@ -2180,9 +2178,7 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc);
* @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
@@ -2192,9 +2188,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);