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

@@ -1199,14 +1199,10 @@ command_find_channel(struct command *cmd,
tok->end - tok->start,
buffer + tok->start);
} else if (json_to_short_channel_id(buffer, tok, &scid)) {
list_for_each(&ld->peers, peer, list) {
*channel = peer_active_channel(peer);
if (!*channel)
continue;
if ((*channel)->scid
&& (*channel)->scid->u64 == scid.u64)
return NULL;
}
*channel = active_channel_by_scid(ld, &scid);
if (*channel)
return NULL;
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Short channel ID not found: '%.*s'",
tok->end - tok->start,