[datastore] Fix #3743
authorDavid Barksdale <amatus@amat.us>
Sun, 19 Mar 2017 20:55:32 +0000 (15:55 -0500)
committerDavid Barksdale <amatus@amat.us>
Sun, 19 Mar 2017 22:38:36 +0000 (17:38 -0500)
commit2dde0202c5590eeb051c1346f2b66293d83b87ce
tree7997191912ee4c70959934d6c9783a0c9f450fec
parentd17d833dfd93a81f3540d472d1be4dfb7e9cbd03
[datastore] Fix #3743

This change adds support for key == NULL to the datastore plugins
and replaces the offset argument with a next_uid and random arguments to
increase performance in the key == NULL case.

With the offset argument a datastore plugin would have to count all
matching keys before fetching the key at the right offset, which would
iterate over the entire database in the case of key == NULL.

The offset argument was used in two ways: to iterate over a set of
matching values and to start iteration at a random matching value. The new API
seperates these into two arguments: if random is true it will return a
random matching value, otherwise next_uid can be set to uid + 1 to return the
next matching value.

The random argument was not added to get_zero_anonymity. This function
is used to periodically insert zero anonymity values into the DHT. I
don't think it's necessary to randomize this.
20 files changed:
src/datastore/datastore.h
src/datastore/datastore_api.c
src/datastore/gnunet-datastore.c
src/datastore/gnunet-service-datastore.c
src/datastore/plugin_datastore_heap.c
src/datastore/plugin_datastore_mysql.c
src/datastore/plugin_datastore_postgres.c
src/datastore/plugin_datastore_sqlite.c
src/datastore/plugin_datastore_template.c
src/datastore/test_datastore_api.c
src/datastore/test_datastore_api_management.c
src/datastore/test_plugin_datastore.c
src/fs/fs_api.h
src/fs/fs_unindex.c
src/fs/gnunet-service-fs_cadet_server.c
src/fs/gnunet-service-fs_pr.c
src/fs/gnunet-service-fs_put.c
src/include/gnunet_datastore_plugin.h
src/include/gnunet_datastore_service.h
src/include/platform.h