mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user