From 0bc2f8714d4cbafed135f9d7d3005d27fbc14ae8 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 30 Jan 2018 19:46:07 +0100 Subject: [PATCH] gossip: Added uintmap based channels map, indexed by scids Signed-off-by: Christian Decker --- gossipd/routing.c | 2 ++ gossipd/routing.h | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/gossipd/routing.c b/gossipd/routing.c index 8fde308ee..7ac876f58 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -68,6 +68,8 @@ struct routing_state *new_routing_state(const tal_t *ctx, rstate->chain_hash = *chain_hash; rstate->local_id = *local_id; list_head_init(&rstate->pending_cannouncement); + uintmap_init(&rstate->channels); + return rstate; } diff --git a/gossipd/routing.h b/gossipd/routing.h index af8fe16cf..bb2bf6320 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -81,6 +81,21 @@ 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); +enum txout_state { + TXOUT_FETCHING, + TXOUT_PRESENT, + TXOUT_MISSING +}; + +struct routing_channel { + struct short_channel_id scid; + enum txout_state state; + u8 *txout_script; + + struct node_connection *connections[2]; + struct node *nodes[2]; +}; + struct routing_state { /* All known nodes. */ struct node_map *nodes; @@ -94,6 +109,9 @@ struct routing_state { /* Our own ID so we can identify local channels */ struct pubkey local_id; + + /* A map of channels indexed by short_channel_ids */ + UINTMAP(struct routing_channel*) channels; }; struct route_hop {