libdht
put.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 naturalpolice
3  * SPDX-License-Identifier: MIT
4  *
5  * Licensed under the MIT License (see LICENSE).
6  */
7 
17 #ifndef DHT_PUT_H_
18 #define DHT_PUT_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #include <dht/node.h>
25 
37 typedef void (*get_callback)(const struct bvalue *val, void *opaque);
38 
48 typedef void (*put_immutable_callback)(int result, void *opaque);
49 
70 typedef void (*put_mutable_callback)(struct bvalue **val, void *opaque);
71 
90 int dht_get_immutable(struct dht_node *node, const unsigned char hash[20],
91  get_callback callback, void *opaque,
92  dht_search_t *handle);
93 
116 int dht_put_immutable(struct dht_node *node, const struct bvalue *v,
117  put_immutable_callback callback, void *opaque,
118  dht_search_t *handle, unsigned char hash[20]);
119 
140 int dht_get_mutable(struct dht_node *node,
141  const unsigned char pubkey[32],
142  const unsigned char *salt, size_t salt_len,
143  get_callback callback, void *opaque,
144  dht_search_t *handle);
145 
168 int dht_put_mutable(struct dht_node *node,
169  const unsigned char secret[64],
170  const unsigned char pubkey[32],
171  const unsigned char *salt, size_t salt_len,
172  put_mutable_callback callback, void *opaque,
173  dht_search_t *handle);
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* DHT_PUT_H_ */
int dht_put_mutable(struct dht_node *node, const unsigned char secret[64], const unsigned char pubkey[32], const unsigned char *salt, size_t salt_len, put_mutable_callback callback, void *opaque, dht_search_t *handle)
Put an mutable value to the DHT.
int dht_put_immutable(struct dht_node *node, const struct bvalue *v, put_immutable_callback callback, void *opaque, dht_search_t *handle, unsigned char hash[20])
Put an immutable value to the DHT.
API for running a DHT node.
DHT node object.
Definition: node.h:140
void(* put_mutable_callback)(struct bvalue **val, void *opaque)
Put mutable callback.
Definition: put.h:70
void(* get_callback)(const struct bvalue *val, void *opaque)
Get complete callback.
Definition: put.h:37
bencoding value.
Definition: bencode.h:32
struct search * dht_search_t
Search handle.
Definition: node.h:165
struct bvalue ** val
array of values
Definition: bencode.h:69
int dht_get_immutable(struct dht_node *node, const unsigned char hash[20], get_callback callback, void *opaque, dht_search_t *handle)
Get an immutable value from the DHT.
int dht_get_mutable(struct dht_node *node, const unsigned char pubkey[32], const unsigned char *salt, size_t salt_len, get_callback callback, void *opaque, dht_search_t *handle)
Get a mutable value from the DHT.
void(* put_immutable_callback)(int result, void *opaque)
Put immutable callback.
Definition: put.h:48