From 0c7ce27a39689d0b1b4e35a64bc38931d864ebcc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 9 Jul 2024 18:12:44 +0930 Subject: [PATCH] plugins/offers: establish_onion_path can have a simple boolean arg for connect_disable. It's always the same string, so simplify the interface. Signed-off-by: Rusty Russell --- plugins/establish_onion_path.c | 8 +++----- plugins/establish_onion_path.h | 4 ++-- plugins/fetchinvoice.c | 6 +++--- plugins/offers_invreq_hook.c | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/establish_onion_path.c b/plugins/establish_onion_path.c index 161180552..8c60a8579 100644 --- a/plugins/establish_onion_path.c +++ b/plugins/establish_onion_path.c @@ -9,7 +9,7 @@ struct connect_info { struct pubkey local_id, dst; - const char *connect_disable; + bool connect_disable; struct gossmap *gossmap; struct command_result *(*cb)(struct command *, const struct pubkey *, @@ -47,9 +47,7 @@ static struct command_result *connect_direct(struct command *cmd, struct out_req *req; if (ci->connect_disable) { - return ci->fail(cmd, - tal_fmt(tmpctx, "%s set: not initiating a new connection", - ci->connect_disable), + return ci->fail(cmd, "fetchinvoice-noconnect set: not initiating a new connection", ci->arg); } @@ -149,7 +147,7 @@ struct command_result *establish_onion_path_(struct command *cmd, struct gossmap *gossmap, const struct pubkey *local_id, const struct pubkey *dst, - const char *connect_disable, + bool connect_disable, struct command_result *(*success)(struct command *, const struct pubkey *, void *arg), diff --git a/plugins/establish_onion_path.h b/plugins/establish_onion_path.h index d73586c3d..8c45f7736 100644 --- a/plugins/establish_onion_path.h +++ b/plugins/establish_onion_path.h @@ -12,7 +12,7 @@ struct gossmap; * @gossmap: a gossip map to do lookup in * @local_id: our own id * @dst: the destination node - * @connect_disable: if non-null, the arg name which is disabling direct connection + * @connect_disable: true if we cannot reach out to connect to nodes. * @success: the success callback * @fail: the failure callback * @arg: callback argument @@ -24,7 +24,7 @@ struct command_result *establish_onion_path_(struct command *cmd, struct gossmap *gossmap, const struct pubkey *local_id, const struct pubkey *dst, - const char *connect_disable, + bool connect_disable, struct command_result *(*success)(struct command *, const struct pubkey *, void *arg), diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c index d5af78782..16269d393 100644 --- a/plugins/fetchinvoice.c +++ b/plugins/fetchinvoice.c @@ -787,7 +787,7 @@ static struct command_result *invreq_done(struct command *cmd, return establish_onion_path(cmd, get_gossmap(cmd->plugin), &local_id, sent->invreq->offer_node_id, - disable_connect ? "fetchinvoice-noconnect" : NULL, + disable_connect, fetchinvoice_path_done, fetchinvoice_path_fail, sent); @@ -1136,7 +1136,7 @@ static struct command_result *createinvoice_done(struct command *cmd, return establish_onion_path(cmd, get_gossmap(cmd->plugin), &local_id, sent->invreq->invreq_payer_id, - disable_connect ? "fetchinvoice-noconnect" : NULL, + disable_connect, sendinvoice_path_done, sendinvoice_path_fail, sent); @@ -1428,7 +1428,7 @@ static struct command_result *json_dev_rawrequest(struct command *cmd, return establish_onion_path(cmd, get_gossmap(cmd->plugin), &local_id, node_id, - disable_connect ? "fetchinvoice-noconnect" : NULL, + disable_connect, fetchinvoice_path_done, fetchinvoice_path_fail, sent); diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c index b0fe68cc2..97dfb9889 100644 --- a/plugins/offers_invreq_hook.c +++ b/plugins/offers_invreq_hook.c @@ -1154,7 +1154,7 @@ struct command_result *handle_invoice_request(struct command *cmd, /* Before any failure, make sure we can reach first node! */ return establish_onion_path(cmd, get_gossmap(cmd->plugin), &id, &reply_path->first_node_id.pubkey, - disable_connect ? "offers-noconnect" : NULL, + disable_connect, invoice_request_path_done, invoice_request_path_fail, ir);