diff options
author | Dimitri Staessens <[email protected]> | 2021-12-04 18:26:58 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2021-12-06 17:52:16 +0100 |
commit | 9422e6be94ac1007e8115a920379fd545055e531 (patch) | |
tree | 31075ad5ee851ef4625e3cafbd821e591e817997 /src/ipcpd/unicast/dir.c | |
parent | 11d2ecc140486949c8d81e984137263ca48d5799 (diff) | |
download | ouroboros-9422e6be94ac1007e8115a920379fd545055e531.tar.gz ouroboros-9422e6be94ac1007e8115a920379fd545055e531.zip |
ipcpd: Move DHT to stack
This makes the DHT a single directory implementation and moves it to
the stack (init/fini instead of create/destroy). This is a step
towards making it a directory policy, in line with our other policy
implementations.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd/unicast/dir.c')
-rw-r--r-- | src/ipcpd/unicast/dir.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/ipcpd/unicast/dir.c b/src/ipcpd/unicast/dir.c index a30908b8..d27cabfa 100644 --- a/src/ipcpd/unicast/dir.c +++ b/src/ipcpd/unicast/dir.c @@ -35,7 +35,6 @@ #include "dir.h" #include "dht.h" -#include "ipcp.h" #include <stdlib.h> #include <string.h> @@ -43,15 +42,9 @@ #include <inttypes.h> #include <limits.h> -#define KAD_B (hash_len(ipcpi.dir_hash_algo) * CHAR_BIT) - -struct ipcp icpci; -struct dht * dht; - int dir_init(void) { - dht = dht_create(ipcpi.dt_addr); - if (dht == NULL) + if (dht_init() < 0) return -ENOMEM; return 0; @@ -59,15 +52,14 @@ int dir_init(void) void dir_fini(void) { - dht_destroy(dht); + dht_fini(); } int dir_bootstrap(void) { log_dbg("Bootstrapping directory."); - /* TODO: get parameters for bootstrap from IRM tool. */ - if (dht_bootstrap(dht, KAD_B, 86400)) { - dht_destroy(dht); + if (dht_bootstrap()) { + dht_fini(); return -ENOMEM; } @@ -78,22 +70,22 @@ int dir_bootstrap(void) { int dir_reg(const uint8_t * hash) { - return dht_reg(dht, hash); + return dht_reg(hash); } int dir_unreg(const uint8_t * hash) { - return dht_unreg(dht, hash); + return dht_unreg(hash); } uint64_t dir_query(const uint8_t * hash) { - return dht_query(dht, hash); + return dht_query(hash); } int dir_wait_running(void) { - if (dht_wait_running(dht)) { + if (dht_wait_running()) { log_warn("Directory did not bootstrap."); return -1; } |