diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-26 21:24:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-26 21:24:03 +0000 |
commit | 7b00dd51218edbd9182caa664cfce185edc2cc45 (patch) | |
tree | 2cea8a9d7085aa6e3d16256f18f7c77f3320bb75 /src/dht/gnunet-service-dht_datacache.h | |
parent | 60ff113fe4e7bb71d5696063b9a9b81eba60a108 (diff) | |
download | gnunet-7b00dd51218edbd9182caa664cfce185edc2cc45.tar.gz gnunet-7b00dd51218edbd9182caa664cfce185edc2cc45.zip |
porting xdht to new service API, major code de-duplication effort
Diffstat (limited to 'src/dht/gnunet-service-dht_datacache.h')
-rw-r--r-- | src/dht/gnunet-service-dht_datacache.h | 95 |
1 files changed, 90 insertions, 5 deletions
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h index 66bfc3bbf..5069883c7 100644 --- a/src/dht/gnunet-service-dht_datacache.h +++ b/src/dht/gnunet-service-dht_datacache.h | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_block_lib.h" | 31 | #include "gnunet_block_lib.h" |
32 | #include "gnunet_dht_service.h" | ||
32 | 33 | ||
33 | /** | 34 | /** |
34 | * Handle a datum we've received from another peer. Cache if | 35 | * Handle a datum we've received from another peer. Cache if |
@@ -44,14 +45,42 @@ | |||
44 | */ | 45 | */ |
45 | void | 46 | void |
46 | GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | 47 | GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, |
47 | const struct GNUNET_HashCode * key, | 48 | const struct GNUNET_HashCode *key, |
48 | unsigned int put_path_length, | 49 | unsigned int put_path_length, |
49 | const struct GNUNET_PeerIdentity *put_path, | 50 | const struct GNUNET_PeerIdentity *put_path, |
50 | enum GNUNET_BLOCK_Type type, size_t data_size, | 51 | enum GNUNET_BLOCK_Type type, |
52 | size_t data_size, | ||
51 | const void *data); | 53 | const void *data); |
52 | 54 | ||
53 | 55 | ||
54 | /** | 56 | /** |
57 | * Handle a result for a GET operation. | ||
58 | * | ||
59 | * @param cls closure | ||
60 | * @param type type of the block | ||
61 | * @param expiration_time when does the content expire | ||
62 | * @param key key for the content | ||
63 | * @param put_path_length number of entries in @a put_path | ||
64 | * @param put_path peers the original PUT traversed (if tracked) | ||
65 | * @param get_path_length number of entries in @a get_path | ||
66 | * @param get_path peers this reply has traversed so far (if tracked) | ||
67 | * @param data payload of the reply | ||
68 | * @param data_size number of bytes in @a data | ||
69 | */ | ||
70 | typedef void | ||
71 | (*GDS_DATACACHE_GetCallback)(void *cls, | ||
72 | enum GNUNET_BLOCK_Type type, | ||
73 | struct GNUNET_TIME_Absolute expiration_time, | ||
74 | const struct GNUNET_HashCode *key, | ||
75 | unsigned int put_path_length, | ||
76 | const struct GNUNET_PeerIdentity *put_path, | ||
77 | unsigned int get_path_length, | ||
78 | const struct GNUNET_PeerIdentity *get_path, | ||
79 | const void *data, | ||
80 | size_t data_size); | ||
81 | |||
82 | |||
83 | /** | ||
55 | * Handle a GET request we've received from another peer. | 84 | * Handle a GET request we've received from another peer. |
56 | * | 85 | * |
57 | * @param key the query | 86 | * @param key the query |
@@ -60,14 +89,70 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, | |||
60 | * @param xquery_size number of bytes in xquery | 89 | * @param xquery_size number of bytes in xquery |
61 | * @param reply_bf where the reply bf is (to be) stored, possibly updated!, can be NULL | 90 | * @param reply_bf where the reply bf is (to be) stored, possibly updated!, can be NULL |
62 | * @param reply_bf_mutator mutation value for reply_bf | 91 | * @param reply_bf_mutator mutation value for reply_bf |
92 | * @param gc function to call on the results | ||
93 | * @param gc_cls closure for @a gc | ||
63 | * @return evaluation result for the local replies | 94 | * @return evaluation result for the local replies |
64 | */ | 95 | */ |
65 | enum GNUNET_BLOCK_EvaluationResult | 96 | enum GNUNET_BLOCK_EvaluationResult |
66 | GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key, | 97 | GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key, |
67 | enum GNUNET_BLOCK_Type type, const void *xquery, | 98 | enum GNUNET_BLOCK_Type type, |
99 | const void *xquery, | ||
68 | size_t xquery_size, | 100 | size_t xquery_size, |
69 | struct GNUNET_CONTAINER_BloomFilter **reply_bf, | 101 | struct GNUNET_CONTAINER_BloomFilter **reply_bf, |
70 | uint32_t reply_bf_mutator); | 102 | uint32_t reply_bf_mutator, |
103 | GDS_DATACACHE_GetCallback gc, | ||
104 | void *gc_cls); | ||
105 | |||
106 | |||
107 | /** | ||
108 | * Obtain a random key from the datacache. | ||
109 | * Used by Whanau for load-balancing. | ||
110 | * | ||
111 | * @param[out] key where to store the key of a random element, | ||
112 | * randomized by PRNG if datacache is empty | ||
113 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the datacache is empty | ||
114 | */ | ||
115 | int | ||
116 | GDS_DATACACHE_get_random_key (struct GNUNET_HashCode *key); | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Send the get result to requesting client. | ||
121 | * | ||
122 | * @param cls closure | ||
123 | * @param options routing options (from GET request) | ||
124 | * @param key key of the requested data. | ||
125 | * @param type block type | ||
126 | * @param put_path_length number of peers in @a put_path | ||
127 | * @param put_path path taken to put the data at its stored location. | ||
128 | * @param expiration when will this result expire? | ||
129 | * @param data payload to store | ||
130 | * @param data_size size of the @a data | ||
131 | */ | ||
132 | typedef void | ||
133 | (*GDS_DATACACHE_SuccessorCallback)(void *cls, | ||
134 | enum GNUNET_DHT_RouteOption options, | ||
135 | const struct GNUNET_HashCode *key, | ||
136 | enum GNUNET_BLOCK_Type type, | ||
137 | unsigned int put_path_length, | ||
138 | const struct GNUNET_PeerIdentity *put_path, | ||
139 | struct GNUNET_TIME_Absolute expiration, | ||
140 | const void *data, | ||
141 | size_t data_size); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Handle a request for data close to a key that we have received from | ||
146 | * another peer. | ||
147 | * | ||
148 | * @param key the location at which the peer is looking for data that is close | ||
149 | * @param cb function to call with the result | ||
150 | * @param cb_cls closure for @a cb | ||
151 | */ | ||
152 | void | ||
153 | GDS_DATACACHE_get_successors (const struct GNUNET_HashCode *key, | ||
154 | GDS_DATACACHE_SuccessorCallback cb, | ||
155 | void *cb_cls); | ||
71 | 156 | ||
72 | 157 | ||
73 | /** | 158 | /** |