mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 16:44:20 +01:00
gossip: Use the channels map to look up by scid
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
a88076b1b0
commit
fa069d7d97
@@ -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 *
|
||||||
|
|||||||
Reference in New Issue
Block a user