aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-07-07 13:42:52 +0200
committerChristian Grothoff <christian@grothoff.org>2022-07-07 13:42:52 +0200
commit2906241b6a21d6009a0d195199f3a08e8f4d4e2a (patch)
treec9946fd81f343008877b41fc8471d13d0051f48a /src/include
parent374e3cf6de48f26f67cf93091a2bfbdab019a6eb (diff)
downloadgnunet-2906241b6a21d6009a0d195199f3a08e8f4d4e2a.tar.gz
gnunet-2906241b6a21d6009a0d195199f3a08e8f4d4e2a.zip
major modification to datacache to store route options (and clean up the API)
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_datacache_lib.h83
-rw-r--r--src/include/gnunet_datacache_plugin.h16
-rw-r--r--src/include/gnunet_dht_service.h7
-rw-r--r--src/include/gnunet_sq_lib.h8
4 files changed, 65 insertions, 49 deletions
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h
index 737a5c845..c4d74524a 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
@@ -51,6 +51,53 @@ extern "C"
51 51
52 52
53/** 53/**
54 * Information about a block stored in the datacache.
55 */
56struct GNUNET_DATACACHE_Block
57{
58 /**
59 * Key of the block.
60 */
61 struct GNUNET_HashCode key;
62
63 /**
64 * When does the block expire?
65 */
66 struct GNUNET_TIME_Absolute expiration_time;
67
68 /**
69 * PUT path taken by the block, array of peer identities.
70 */
71 const struct GNUNET_DHT_PathElement *put_path;
72
73 /**
74 * Actual block data.
75 */
76 const void *data;
77
78 /**
79 * Number of bytes in @a data.
80 */
81 size_t data_size;
82
83 /**
84 * Length of the @e put_path array.
85 */
86 unsigned int put_path_length;
87
88 /**
89 * Type of the block.
90 */
91 enum GNUNET_BLOCK_Type type;
92
93 /**
94 * Options for routing for the block.
95 */
96 enum GNUNET_DHT_RouteOption ro;
97};
98
99
100/**
54 * Handle to the cache. 101 * Handle to the cache.
55 */ 102 */
56struct GNUNET_DATACACHE_Handle; 103struct GNUNET_DATACACHE_Handle;
@@ -81,50 +128,26 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h);
81 * An iterator over a set of items stored in the datacache. 128 * An iterator over a set of items stored in the datacache.
82 * 129 *
83 * @param cls closure 130 * @param cls closure
84 * @param key key for the content 131 * @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 132 * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort
92 */ 133 */
93typedef enum GNUNET_GenericReturnValue 134typedef enum GNUNET_GenericReturnValue
94(*GNUNET_DATACACHE_Iterator)(void *cls, 135(*GNUNET_DATACACHE_Iterator)(void *cls,
95 const struct GNUNET_HashCode *key, 136 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 137
103 138
104/** 139/**
105 * Store an item in the datacache. 140 * Store an item in the datacache.
106 * 141 *
107 * @param h handle to the datacache 142 * @param h handle to the datacache
108 * @param key key to store data under 143 * @param xor_distance how close is the block's key to our pid?
109 * @param how close is @a key to our pid? 144 * @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 145 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error, #GNUNET_NO if duplicate
117 */ 146 */
118enum GNUNET_GenericReturnValue 147enum GNUNET_GenericReturnValue
119GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, 148GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
120 const struct GNUNET_HashCode *key,
121 uint32_t xor_distance, 149 uint32_t xor_distance,
122 size_t data_size, 150 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 151
129 152
130/** 153/**
diff --git a/src/include/gnunet_datacache_plugin.h b/src/include/gnunet_datacache_plugin.h
index 34bf5f277..7e63d87d9 100644
--- a/src/include/gnunet_datacache_plugin.h
+++ b/src/include/gnunet_datacache_plugin.h
@@ -105,26 +105,14 @@ struct GNUNET_DATACACHE_PluginFunctions
105 * Store an item in the datastore. 105 * Store an item in the datastore.
106 * 106 *
107 * @param cls closure (internal context for the plugin) 107 * @param cls closure (internal context for the plugin)
108 * @param key key to store the value under
109 * @param xor_distance how close is @a key to our PID? 108 * @param xor_distance how close is @a key to our PID?
110 * @param size number of bytes in @a data 109 * @param block data to store
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 0 if duplicate, -1 on error, number of bytes used otherwise 110 * @return 0 if duplicate, -1 on error, number of bytes used otherwise
117 */ 111 */
118 ssize_t 112 ssize_t
119 (*put) (void *cls, 113 (*put) (void *cls,
120 const struct GNUNET_HashCode *key,
121 uint32_t xor_distance, 114 uint32_t xor_distance,
122 size_t size, 115 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 116
129 117
130 /** 118 /**
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index 22b659d66..d683ae0bf 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -106,10 +106,15 @@ enum GNUNET_DHT_RouteOption
106 GNUNET_DHT_RO_FIND_APPROXIMATE = 4, 106 GNUNET_DHT_RO_FIND_APPROXIMATE = 4,
107 107
108 /** 108 /**
109 * Flag set if the path was truncated.
110 */
111 GNUNET_DHT_RO_TRUNCATED = 8,
112
113 /**
109 * Flag given to monitors if this was the last hop for a GET/PUT. 114 * Flag given to monitors if this was the last hop for a GET/PUT.
110 * This is only used for internal processing. 115 * This is only used for internal processing.
111 */ 116 */
112 GNUNET_DHT_RO_LAST_HOP = 65535 117 GNUNET_DHT_RO_LAST_HOP = 32768
113}; 118};
114 119
115 120
diff --git a/src/include/gnunet_sq_lib.h b/src/include/gnunet_sq_lib.h
index e89ded07e..51713e755 100644
--- a/src/include/gnunet_sq_lib.h
+++ b/src/include/gnunet_sq_lib.h
@@ -194,7 +194,7 @@ GNUNET_SQ_query_param_uint64 (const uint64_t *x);
194 * @param params parameters to the statement 194 * @param params parameters to the statement
195 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 195 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
196 */ 196 */
197int 197enum GNUNET_GenericReturnValue
198GNUNET_SQ_bind (sqlite3_stmt *stmt, 198GNUNET_SQ_bind (sqlite3_stmt *stmt,
199 const struct GNUNET_SQ_QueryParam *params); 199 const struct GNUNET_SQ_QueryParam *params);
200 200
@@ -498,7 +498,7 @@ GNUNET_SQ_make_prepare (const char *sql,
498 * @param ps array of statements to prepare 498 * @param ps array of statements to prepare
499 * @return #GNUNET_OK on success 499 * @return #GNUNET_OK on success
500 */ 500 */
501int 501enum GNUNET_GenericReturnValue
502GNUNET_SQ_prepare (sqlite3 *dbh, 502GNUNET_SQ_prepare (sqlite3 *dbh,
503 const struct GNUNET_SQ_PrepareStatement *ps); 503 const struct GNUNET_SQ_PrepareStatement *ps);
504 504
@@ -520,7 +520,7 @@ struct GNUNET_SQ_ExecuteStatement
520 /** 520 /**
521 * Should we ignore errors? 521 * Should we ignore errors?
522 */ 522 */
523 int ignore_errors; 523 bool ignore_errors;
524}; 524};
525 525
526 526
@@ -560,7 +560,7 @@ GNUNET_SQ_make_try_execute (const char *sql);
560 * @return #GNUNET_OK on success (modulo statements where errors can be ignored) 560 * @return #GNUNET_OK on success (modulo statements where errors can be ignored)
561 * #GNUNET_SYSERR on error 561 * #GNUNET_SYSERR on error
562 */ 562 */
563int 563enum GNUNET_GenericReturnValue
564GNUNET_SQ_exec_statements (sqlite3 *dbh, 564GNUNET_SQ_exec_statements (sqlite3 *dbh,
565 const struct GNUNET_SQ_ExecuteStatement *es); 565 const struct GNUNET_SQ_ExecuteStatement *es);
566 566