aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_datacache_plugin.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-04-28 15:05:12 +0000
committerChristian Grothoff <christian@grothoff.org>2015-04-28 15:05:12 +0000
commit7581e114280c0c33f375b5d3ba49508b82680755 (patch)
treed24afeeda69f94b70d1dc325db06810a4b0b1be0 /src/include/gnunet_datacache_plugin.h
parent553909348c19833330ad94d7a1064eaf48f97e3f (diff)
downloadgnunet-7581e114280c0c33f375b5d3ba49508b82680755.tar.gz
gnunet-7581e114280c0c33f375b5d3ba49508b82680755.zip
extending datacache API with function to return random element, implemented (only) in heap plugin right now
Diffstat (limited to 'src/include/gnunet_datacache_plugin.h')
-rw-r--r--src/include/gnunet_datacache_plugin.h46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/include/gnunet_datacache_plugin.h b/src/include/gnunet_datacache_plugin.h
index 347ed9a59..34cf8fecc 100644
--- a/src/include/gnunet_datacache_plugin.h
+++ b/src/include/gnunet_datacache_plugin.h
@@ -45,9 +45,10 @@ extern "C"
45 * @param key key of the content that was deleted 45 * @param key key of the content that was deleted
46 * @param size number of bytes that were made available 46 * @param size number of bytes that were made available
47 */ 47 */
48typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback) (void *cls, 48typedef void
49 const struct GNUNET_HashCode * 49(*GNUNET_DATACACHE_DeleteNotifyCallback) (void *cls,
50 key, size_t size); 50 const struct GNUNET_HashCode *key,
51 size_t size);
51 52
52 53
53/** 54/**
@@ -58,7 +59,6 @@ typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback) (void *cls,
58struct GNUNET_DATACACHE_PluginEnvironment 59struct GNUNET_DATACACHE_PluginEnvironment
59{ 60{
60 61
61
62 /** 62 /**
63 * Configuration to use. 63 * Configuration to use.
64 */ 64 */
@@ -103,46 +103,62 @@ struct GNUNET_DATACACHE_PluginFunctions
103 * Store an item in the datastore. 103 * Store an item in the datastore.
104 * 104 *
105 * @param cls closure (internal context for the plugin) 105 * @param cls closure (internal context for the plugin)
106 * @param size number of bytes in data 106 * @param key key to store the value under
107 * @param size number of bytes in @a data
107 * @param data data to store 108 * @param data data to store
108 * @param type type of the value 109 * @param type type of the value
109 * @param discard_time when to discard the value in any case 110 * @param discard_time when to discard the value in any case
110 * @param path_info_len number of entries in 'path_info' 111 * @param path_info_len number of entries in @a path_info
111 * @param path_info a path through the network 112 * @param path_info a path through the network
112 * @return 0 if duplicate, -1 on error, number of bytes used otherwise 113 * @return 0 if duplicate, -1 on error, number of bytes used otherwise
113 */ 114 */
114 ssize_t (*put) (void *cls, const struct GNUNET_HashCode * key, size_t size, 115 ssize_t (*put) (void *cls,
115 const char *data, enum GNUNET_BLOCK_Type type, 116 const struct GNUNET_HashCode *key,
117 size_t size,
118 const char *data,
119 enum GNUNET_BLOCK_Type type,
116 struct GNUNET_TIME_Absolute discard_time, 120 struct GNUNET_TIME_Absolute discard_time,
117 unsigned int path_info_len, 121 unsigned int path_info_len,
118 const struct GNUNET_PeerIdentity *path_info); 122 const struct GNUNET_PeerIdentity *path_info);
119 123
120
121 /** 124 /**
122 * Iterate over the results for a particular key 125 * Iterate over the results for a particular key
123 * in the datastore. 126 * in the datastore.
124 * 127 *
125 * @param cls closure (internal context for the plugin) 128 * @param cls closure (internal context for the plugin)
126 * @param key 129 * @param key key to look for
127 * @param type entries of which type are relevant? 130 * @param type entries of which type are relevant?
128 * @param iter maybe NULL (to just count) 131 * @param iter maybe NULL (to just count)
129 * @param iter_cls closure for iter 132 * @param iter_cls closure for @a iter
130 * @return the number of results found 133 * @return the number of results found
131 */ 134 */
132 unsigned int (*get) (void *cls, const struct GNUNET_HashCode * key, 135 unsigned int (*get) (void *cls,
136 const struct GNUNET_HashCode * key,
133 enum GNUNET_BLOCK_Type type, 137 enum GNUNET_BLOCK_Type type,
134 GNUNET_DATACACHE_Iterator iter, void *iter_cls); 138 GNUNET_DATACACHE_Iterator iter,
135 139 void *iter_cls);
136 140
137 /** 141 /**
138 * Delete the entry with the lowest expiration value 142 * Delete the entry with the lowest expiration value
139 * from the datacache right now. 143 * from the datacache right now.
140 * 144 *
141 * @param cls closure (internal context for the plugin) 145 * @param cls closure (internal context for the plugin)
142 * @return GNUNET_OK on success, GNUNET_SYSERR on error 146 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
143 */ 147 */
144 int (*del) (void *cls); 148 int (*del) (void *cls);
145 149
150 /**
151 * Return a random value from the datastore.
152 *
153 * @param cls closure (internal context for the plugin)
154 * @param iter maybe NULL (to just count)
155 * @param iter_cls closure for @a iter
156 * @return the number of results found (zero or one)
157 */
158 unsigned int (*get_random) (void *cls,
159 GNUNET_DATACACHE_Iterator iter,
160 void *iter_cls);
161
146 162
147}; 163};
148 164