HOSTNAME = localhost
HOME = $SERVICEHOME
CONFIG = $DEFAULTCONFIG
-BINARY = gnunet-service-fs
+BINARY = gnunet-service-fs-new
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
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
\fB\-P \fINAME\fR, \fB\-\-pseudonym=\fINAME\fR
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.
* @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
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,
/**
- * 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
* (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;
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))),
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 (
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))
{
get_type (crc->i),
get_priority (crc->i),
get_anonymity (crc->i),
+ 0,
get_expiration (crc->i),
1, 1, TIMEOUT,
&check_success,
get_type (42),
get_priority (42),
get_anonymity (42),
+ 0,
get_expiration (42),
1, 1, TIMEOUT,
&check_success,
get_type (42),
get_priority (43),
get_anonymity (43),
+ 0,
get_expiration (43),
1, 1, TIMEOUT,
&check_success,
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))
{
get_type (crc->i),
get_priority (crc->i),
get_anonymity (crc->i),
+ 0,
get_expiration (crc->i),
1, 1, TIMEOUT,
&check_success,
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))
{
/*
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
(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 !=
(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;
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 !=
(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;
* @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)
*/
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;
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?
} 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?
*/
/*
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
* @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 *
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;
keywords,
meta,
do_index,
- anonymity,
- priority,
- expirationTime);
+ bo);
if (ret == NULL)
return NULL;
ret->h = 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 *
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)
{
keywords,
meta,
do_index,
- anonymity,
- priority,
- expirationTime);
+ bo);
}
* @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 *
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;
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;
}
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;
};
dsc->scanner,
dsc->scanner_cls,
dsc->do_index,
- dsc->anonymity,
- dsc->priority,
- dsc->expiration,
+ dsc->bo,
&dsc->emsg);
if (NULL == fi)
{
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);
* @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)
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)
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))
* @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
*/
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;
h,
filename,
do_index,
- anonymity,
- priority,
- expirationTime,
+ bo,
&dirproc,
&dc,
emsg);
client_info,
ksk,
meta,
- anonymity,
- priority,
- expirationTime);
+ bo);
GNUNET_CONTAINER_meta_data_destroy (meta);
ret->data.dir.entries = dc.entries;
while (dc.entries != NULL)
* @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 *
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;
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;
}
(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)
(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;
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);
}
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);
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.
*/
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,
* @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
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)
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);
}
* @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
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)
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,
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);
}
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);
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,
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,
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;
}
p->keywords,
p->meta,
p->chk_uri,
- p->expirationTime,
- p->anonymity,
- p->priority,
+ &p->bo,
pc->options,
&publish_kblocks_cont,
pc);
* @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)
*/
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;
* @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)
*/
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;
* @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)
*/
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;
/**
* When should the KBlocks expire?
*/
- struct GNUNET_TIME_Absolute expirationTime;
+ struct GNUNET_FS_BlockOptions bo;
/**
* Size of the serialized metadata.
*/
unsigned int i;
- /**
- * Anonymity level for the KBlocks.
- */
- uint32_t anonymity;
-
- /**
- * Priority for the KBlocks.
- */
- uint32_t priority;
};
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,
* @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
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)
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))
/*
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
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);
daemon->publish_tmp_file,
NULL, NULL,
do_index,
- anonymity,
- 42 /* priority */,
- GNUNET_TIME_relative_to_absolute (CONTENT_LIFETIME));
+ &bo);
}
else
{
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,
#include "platform.h"
#include "gnunet_fs_service.h"
-/**
- * -a optiton.
- */
-static unsigned int anonymity;
-
/**
* -C option
*/
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.
ksk_uri,
ns,
adv_metadata,
- anonymity,
- priority,
- expiration,
+ &bo,
root_identifier,
&post_advertising,
NULL);
/**
- * 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
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"),
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},
/*
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
#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;
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;
* @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
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;
next_id,
meta,
uri,
- GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
- anonymity,
- priority,
+ &bo,
GNUNET_FS_PUBLISH_OPTION_NONE,
uri_sks_continuation,
NULL);
topKeywords,
meta,
uri,
- GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
- anonymity,
- priority,
+ &bo,
GNUNET_FS_PUBLISH_OPTION_NONE,
&uri_ksk_continuation,
NULL);
&GNUNET_FS_directory_scanner_default,
plugins,
!do_insert,
- anonymity,
- priority,
- GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION),
+ &bo,
&emsg);
}
else
keywords,
NULL,
!do_insert,
- anonymity,
- priority,
- GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION));
+ &bo);
GNUNET_break (fi != NULL);
GNUNET_FS_uri_destroy (keywords);
}
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"),
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)"),
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);
}
}
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);
};
GSF_core = GNUNET_CORE_connect (GSF_cfg,
- 1, /* larger? */
+ 2, /* larger? */
NULL,
&peer_init_handler,
&peer_connect_handler,
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,
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,
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);
}
}
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,
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,
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);
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");
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);
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");
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,
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);
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;
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,
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",
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);
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,
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);
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);
{
struct GNUNET_CONTAINER_MetaData *meta;
struct GNUNET_FS_Namespace *ns;
- struct GNUNET_TIME_Absolute expiration;
+ struct GNUNET_FS_BlockOptions bo;
if (NULL != emsg)
{
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);
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;
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,
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
{
const struct GNUNET_FS_Uri *uri,
const char *emsg)
{
+
GNUNET_assert (NULL == emsg);
err = 1;
GNUNET_FS_namespace_list_updateable (ns,
"future",
meta,
uri_next,
- expiration,
- 1, 1,
+ &bo,
GNUNET_FS_PUBLISH_OPTION_NONE,
&sks_cont_next,
NULL);
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 =
"next",
meta,
uri_this,
- expiration,
- 1, 1,
+ &bo,
GNUNET_FS_PUBLISH_OPTION_NONE,
&sks_cont_this,
NULL);
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,
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);
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");
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);
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;
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,
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);
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");
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,
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);
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");
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);
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");
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);
/*
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
/**
* 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
* @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
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,
/**
- * 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
* (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);
/**
};
+/**
+ * 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.
*/
* @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
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);
* @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 *
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);
/**
* @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 *
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);
/**
* @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 *
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);
/**
* @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)
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);
* @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)
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);
* @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
*/
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);
* @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 *
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);
/**
* @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
*/
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);
* @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
*/
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);
* @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
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);