diff options
author | Diadlo <polsha3@gmail.com> | 2017-06-04 23:47:18 +0300 |
---|---|---|
committer | Diadlo <polsha3@gmail.com> | 2017-06-05 01:51:11 +0300 |
commit | b3174bb6c4cf1f98d51d45a744b6cfbd3fe61ce0 (patch) | |
tree | 21ec50b69b5a4b255a65ca7ba831901ff5eead6d /toxcore/DHT.h | |
parent | c12ef2213800d34df768bf5308d6ac79ecee575a (diff) |
Extract SharedKey struct and use it as var instead of indexing
Diffstat (limited to 'toxcore/DHT.h')
-rw-r--r-- | toxcore/DHT.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/toxcore/DHT.h b/toxcore/DHT.h index e70094cd..4b3b45e1 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h | |||
@@ -214,14 +214,17 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed | |||
214 | /* struct to store some shared keys so we don't have to regenerate them for each request. */ | 214 | /* struct to store some shared keys so we don't have to regenerate them for each request. */ |
215 | #define MAX_KEYS_PER_SLOT 4 | 215 | #define MAX_KEYS_PER_SLOT 4 |
216 | #define KEYS_TIMEOUT 600 | 216 | #define KEYS_TIMEOUT 600 |
217 | |||
217 | typedef struct { | 218 | typedef struct { |
218 | struct { | 219 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
219 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 220 | uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; |
220 | uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; | 221 | uint32_t times_requested; |
221 | uint32_t times_requested; | 222 | uint8_t stored; /* 0 if not, 1 if is */ |
222 | uint8_t stored; /* 0 if not, 1 if is */ | 223 | uint64_t time_last_requested; |
223 | uint64_t time_last_requested; | 224 | } Shared_Key; |
224 | } keys[256 * MAX_KEYS_PER_SLOT]; | 225 | |
226 | typedef struct { | ||
227 | Shared_Key keys[256 * MAX_KEYS_PER_SLOT]; | ||
225 | } Shared_Keys; | 228 | } Shared_Keys; |
226 | 229 | ||
227 | /*----------------------------------------------------------------------------------*/ | 230 | /*----------------------------------------------------------------------------------*/ |