lightingd: do a local short_channel_id lookup for forwarding.

Even without optimization, it's faster to walk all the channels than
ping another daemon and wait for the response.

Changelog-Changed: Forwarding messages is now much faster (less inter-daemon traffic)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-02-27 14:56:36 +10:30
parent 40e3566e9a
commit f8a21f16c9
8 changed files with 30 additions and 132 deletions

View File

@@ -328,6 +328,22 @@ struct channel *active_channel_by_id(struct lightningd *ld,
return peer_active_channel(peer);
}
struct channel *active_channel_by_scid(struct lightningd *ld,
const struct short_channel_id *scid)
{
struct peer *p;
struct channel *chan;
list_for_each(&ld->peers, p, list) {
list_for_each(&p->channels, chan, list) {
if (channel_active(chan)
&& chan->scid
&& short_channel_id_eq(scid, chan->scid))
return chan;
}
}
return NULL;
}
struct channel *channel_by_dbid(struct lightningd *ld, const u64 dbid)
{
struct peer *p;