From 5d10093da397b21a307a226ba774e5d88313feb6 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 21 Jan 2017 15:13:10 +0100 Subject: [PATCH] refactor: Moving the node_map definition into routing.h This allows us to move some legacy functions closer to where they are actually used, and not worry about them when including routing.h into the new subdaemons. `struct peer` is the main culprit here. --- daemon/routing.c | 10 +++------- daemon/routing.h | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/daemon/routing.c b/daemon/routing.c index e894f0180..c86f89fde 100644 --- a/daemon/routing.c +++ b/daemon/routing.c @@ -3,12 +3,10 @@ #include "log.h" #include "overflows.h" #include "packets.h" -#include "peer.h" #include "pseudorand.h" #include "routing.h" #include #include -#include #include #include @@ -24,23 +22,21 @@ struct routing_state *new_routing_state(const tal_t *ctx, struct log *base_log) } -static const secp256k1_pubkey *keyof_node(const struct node *n) +const secp256k1_pubkey *node_map_keyof_node(const struct node *n) { return &n->id.pubkey; } -static size_t hash_key(const secp256k1_pubkey *key) +size_t node_map_hash_key(const secp256k1_pubkey *key) { return siphash24(siphash_seed(), key, sizeof(*key)); } -static bool node_eq(const struct node *n, const secp256k1_pubkey *key) +bool node_map_node_eq(const struct node *n, const secp256k1_pubkey *key) { return structeq(&n->id.pubkey, key); } -HTABLE_DEFINE_TYPE(struct node, keyof_node, hash_key, node_eq, node_map); - struct node_map *empty_node_map(const tal_t *ctx) { struct node_map *map = tal(ctx, struct node_map); diff --git a/daemon/routing.h b/daemon/routing.h index 79185878f..2136502c0 100644 --- a/daemon/routing.h +++ b/daemon/routing.h @@ -3,6 +3,7 @@ #include "config.h" #include "bitcoin/pubkey.h" #include "wire/wire.h" +#include #define ROUTING_MAX_HOPS 20 @@ -70,6 +71,11 @@ struct node { u8 *node_announcement; }; +const secp256k1_pubkey *node_map_keyof_node(const struct node *n); +size_t node_map_hash_key(const secp256k1_pubkey *key); +bool node_map_node_eq(const struct node *n, const secp256k1_pubkey *key); +HTABLE_DEFINE_TYPE(struct node, node_map_keyof_node, node_map_hash_key, node_map_node_eq, node_map); + struct lightningd_state; struct routing_state {