Browse Source

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.
ppa-0.6.1
Christian Decker 8 years ago
committed by Rusty Russell
parent
commit
5d10093da3
  1. 10
      daemon/routing.c
  2. 6
      daemon/routing.h

10
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 <ccan/array_size/array_size.h>
#include <ccan/crypto/siphash24/siphash24.h>
#include <ccan/htable/htable_type.h>
#include <ccan/structeq/structeq.h>
#include <inttypes.h>
@ -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);

6
daemon/routing.h

@ -3,6 +3,7 @@
#include "config.h"
#include "bitcoin/pubkey.h"
#include "wire/wire.h"
#include <ccan/htable/htable_type.h>
#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 {

Loading…
Cancel
Save