Browse Source

gossip: Use the channels map to look up by scid

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
fa069d7d97
  1. 22
      gossipd/routing.c

22
gossipd/routing.c

@ -183,23 +183,13 @@ struct node_connection *get_connection_by_scid(const struct routing_state *rstat
const struct short_channel_id *schanid, const struct short_channel_id *schanid,
const u8 direction) const u8 direction)
{ {
struct node *n; u64 scid = short_channel_id_to_uint(schanid);
int i, num_conn; struct routing_channel *chan = uintmap_get(&rstate->channels, scid);
struct node_map *nodes = rstate->nodes;
struct node_connection *c;
struct node_map_iter it;
//FIXME(cdecker) We probably want to speed this up by indexing by chanid. if (chan == NULL)
for (n = node_map_first(nodes, &it); n; n = node_map_next(nodes, &it)) { return NULL;
num_conn = tal_count(n->out); else
for (i = 0; i < num_conn; i++){ return chan->connections[direction];
c = n->out[i];
if (short_channel_id_eq(&c->short_channel_id, schanid) &&
(c->flags&0x1) == direction)
return c;
}
}
return NULL;
} }
static struct node_connection * static struct node_connection *

Loading…
Cancel
Save