aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_datacache_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_datacache_lib.h')
-rw-r--r--src/include/gnunet_datacache_lib.h95
1 files changed, 65 insertions, 30 deletions
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h
index 737a5c845..2c7bf1e8f 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, 2015 GNUnet e.V. 3 Copyright (C) 2006, 2009, 2015, 2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -19,6 +19,9 @@
19 */ 19 */
20 20
21/** 21/**
22 * @addtogroup dht_libs DHT and support libraries
23 * @{
24 *
22 * @author Christian Grothoff 25 * @author Christian Grothoff
23 * 26 *
24 * @file 27 * @file
@@ -37,6 +40,7 @@
37#ifndef GNUNET_DATACACHE_LIB_H 40#ifndef GNUNET_DATACACHE_LIB_H
38#define GNUNET_DATACACHE_LIB_H 41#define GNUNET_DATACACHE_LIB_H
39 42
43
40#include "gnunet_util_lib.h" 44#include "gnunet_util_lib.h"
41#include "gnunet_block_lib.h" 45#include "gnunet_block_lib.h"
42#include "gnunet_dht_service.h" 46#include "gnunet_dht_service.h"
@@ -51,6 +55,59 @@ extern "C"
51 55
52 56
53/** 57/**
58 * Information about a block stored in the datacache.
59 */
60struct GNUNET_DATACACHE_Block
61{
62 /**
63 * Key of the block.
64 */
65 struct GNUNET_HashCode key;
66
67 /**
68 * When does the block expire?
69 */
70 struct GNUNET_TIME_Absolute expiration_time;
71
72 /**
73 * If the path was truncated, this is the peer
74 * ID at which the path was truncated.
75 */
76 struct GNUNET_PeerIdentity trunc_peer;
77
78 /**
79 * PUT path taken by the block, array of peer identities.
80 */
81 const struct GNUNET_DHT_PathElement *put_path;
82
83 /**
84 * Actual block data.
85 */
86 const void *data;
87
88 /**
89 * Number of bytes in @a data.
90 */
91 size_t data_size;
92
93 /**
94 * Length of the @e put_path array.
95 */
96 unsigned int put_path_length;
97
98 /**
99 * Type of the block.
100 */
101 enum GNUNET_BLOCK_Type type;
102
103 /**
104 * Options for routing for the block.
105 */
106 enum GNUNET_DHT_RouteOption ro;
107};
108
109
110/**
54 * Handle to the cache. 111 * Handle to the cache.
55 */ 112 */
56struct GNUNET_DATACACHE_Handle; 113struct GNUNET_DATACACHE_Handle;
@@ -81,50 +138,26 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h);
81 * An iterator over a set of items stored in the datacache. 138 * An iterator over a set of items stored in the datacache.
82 * 139 *
83 * @param cls closure 140 * @param cls closure
84 * @param key key for the content 141 * @param block a block from the datacache
85 * @param data_size number of bytes in @a data
86 * @param data content stored
87 * @param type type of the content
88 * @param exp when will the content expire?
89 * @param path_info_len number of entries in @a path_info
90 * @param path_info a path through the network
91 * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort 142 * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort
92 */ 143 */
93typedef enum GNUNET_GenericReturnValue 144typedef enum GNUNET_GenericReturnValue
94(*GNUNET_DATACACHE_Iterator)(void *cls, 145(*GNUNET_DATACACHE_Iterator)(void *cls,
95 const struct GNUNET_HashCode *key, 146 const struct GNUNET_DATACACHE_Block *block);
96 size_t data_size,
97 const char *data,
98 enum GNUNET_BLOCK_Type type,
99 struct GNUNET_TIME_Absolute exp,
100 unsigned int path_info_len,
101 const struct GNUNET_DHT_PathElement *path_info);
102 147
103 148
104/** 149/**
105 * Store an item in the datacache. 150 * Store an item in the datacache.
106 * 151 *
107 * @param h handle to the datacache 152 * @param h handle to the datacache
108 * @param key key to store data under 153 * @param xor_distance how close is the block's key to our pid?
109 * @param how close is @a key to our pid? 154 * @param block actual block data to store
110 * @param data_size number of bytes in @a data
111 * @param data data to store
112 * @param type type of the value
113 * @param discard_time when to discard the value in any case
114 * @param path_info_len number of entries in @a path_info
115 * @param path_info a path through the network
116 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate 155 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate
117 */ 156 */
118enum GNUNET_GenericReturnValue 157enum GNUNET_GenericReturnValue
119GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, 158GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
120 const struct GNUNET_HashCode *key,
121 uint32_t xor_distance, 159 uint32_t xor_distance,
122 size_t data_size, 160 const struct GNUNET_DATACACHE_Block *block);
123 const char *data,
124 enum GNUNET_BLOCK_Type type,
125 struct GNUNET_TIME_Absolute discard_time,
126 unsigned int path_info_len,
127 const struct GNUNET_DHT_PathElement *path_info);
128 161
129 162
130/** 163/**
@@ -179,3 +212,5 @@ GNUNET_DATACACHE_get_closest (struct GNUNET_DATACACHE_Handle *h,
179#endif 212#endif
180 213
181/** @} */ /* end of group */ 214/** @} */ /* end of group */
215
216/** @} */ /* end of group addition */