aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_datacache_lib.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_lib.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_lib.h')
-rw-r--r--src/include/gnunet_datacache_lib.h57
1 files changed, 39 insertions, 18 deletions
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h
index 5e2ad1c1d..f3761bd89 100644
--- a/src/include/gnunet_datacache_lib.h
+++ b/src/include/gnunet_datacache_lib.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2006, 2009 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2006, 2009, 2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -75,21 +75,23 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h);
75 * 75 *
76 * @param cls closure 76 * @param cls closure
77 * @param key key for the content 77 * @param key key for the content
78 * @param size number of bytes in data 78 * @param data_size number of bytes in @a data
79 * @param data content stored 79 * @param data content stored
80 * @param type type of the content 80 * @param type type of the content
81 * @param exp when will the content expire? 81 * @param exp when will the content expire?
82 * @param path_info_len number of entries in 'path_info' 82 * @param path_info_len number of entries in @a path_info
83 * @param path_info a path through the network 83 * @param path_info a path through the network
84 * @return GNUNET_OK to continue iterating, GNUNET_SYSERR to abort 84 * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort
85 */ 85 */
86typedef int (*GNUNET_DATACACHE_Iterator) (void *cls, 86typedef int
87 const struct GNUNET_HashCode *key, 87(*GNUNET_DATACACHE_Iterator) (void *cls,
88 size_t size, const char *data, 88 const struct GNUNET_HashCode *key,
89 enum GNUNET_BLOCK_Type type, 89 size_t data_size,
90 struct GNUNET_TIME_Absolute exp, 90 const char *data,
91 unsigned int path_info_len, 91 enum GNUNET_BLOCK_Type type,
92 const struct GNUNET_PeerIdentity *path_info); 92 struct GNUNET_TIME_Absolute exp,
93 unsigned int path_info_len,
94 const struct GNUNET_PeerIdentity *path_info);
93 95
94 96
95/** 97/**
@@ -97,18 +99,20 @@ typedef int (*GNUNET_DATACACHE_Iterator) (void *cls,
97 * 99 *
98 * @param h handle to the datacache 100 * @param h handle to the datacache
99 * @param key key to store data under 101 * @param key key to store data under
100 * @param size number of bytes in data 102 * @param data_size number of bytes in @a data
101 * @param data data to store 103 * @param data data to store
102 * @param type type of the value 104 * @param type type of the value
103 * @param discard_time when to discard the value in any case 105 * @param discard_time when to discard the value in any case
104 * @param path_info_len number of entries in 'path_info' 106 * @param path_info_len number of entries in @a path_info
105 * @param path_info a path through the network 107 * @param path_info a path through the network
106 * @return GNUNET_OK on success, GNUNET_SYSERR on error, GNUNET_NO if duplicate 108 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate
107 */ 109 */
108int 110int
109GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, 111GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
110 const struct GNUNET_HashCode * key, size_t size, 112 const struct GNUNET_HashCode *key,
111 const char *data, enum GNUNET_BLOCK_Type type, 113 size_t data_size,
114 const char *data,
115 enum GNUNET_BLOCK_Type type,
112 struct GNUNET_TIME_Absolute discard_time, 116 struct GNUNET_TIME_Absolute discard_time,
113 unsigned int path_info_len, 117 unsigned int path_info_len,
114 const struct GNUNET_PeerIdentity *path_info); 118 const struct GNUNET_PeerIdentity *path_info);
@@ -122,15 +126,32 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
122 * @param key what to look up 126 * @param key what to look up
123 * @param type entries of which type are relevant? 127 * @param type entries of which type are relevant?
124 * @param iter maybe NULL (to just count) 128 * @param iter maybe NULL (to just count)
125 * @param iter_cls closure for iter 129 * @param iter_cls closure for @a iter
126 * @return the number of results found 130 * @return the number of results found
127 */ 131 */
128unsigned int 132unsigned int
129GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, 133GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
130 const struct GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type, 134 const struct GNUNET_HashCode *key,
135 enum GNUNET_BLOCK_Type type,
131 GNUNET_DATACACHE_Iterator iter, void *iter_cls); 136 GNUNET_DATACACHE_Iterator iter, void *iter_cls);
132 137
133 138
139/**
140 * Obtain a random element from the datacache.
141 *
142 * @param h handle to the datacache
143 * @param iter maybe NULL (to just count)
144 * @param iter_cls closure for @a iter
145 * @return the number of results found (zero or 1)
146 */
147unsigned int
148GNUNET_DATACACHE_get_random (struct GNUNET_DATACACHE_Handle *h,
149 GNUNET_DATACACHE_Iterator iter,
150 void *iter_cls);
151
152
153
154
134#if 0 /* keep Emacsens' auto-indent happy */ 155#if 0 /* keep Emacsens' auto-indent happy */
135{ 156{
136#endif 157#endif