From add822a07239d0f5af2b43b8e69fdb8645e400cd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 17 Dec 2018 14:22:08 +1030 Subject: [PATCH] jsonrpc: don't be coy with details for command_its_complicated(). Obviously the Facebook relationship status joke was a bit subtle, but I've continued it anyway because I'm especially susceptible to Dad jokes. Suggested-by: @niftynei Signed-off-by: Rusty Russell --- lightningd/invoice.c | 8 ++++++-- lightningd/jsonrpc.c | 3 ++- lightningd/jsonrpc.h | 2 +- lightningd/pay.c | 7 +++++-- lightningd/test/run-invoice-select-inchan.c | 12 ++++++++---- wallet/test/run-wallet.c | 10 +++++----- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/lightningd/invoice.c b/lightningd/invoice.c index e6771f58e..9e42d5ad2 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -572,7 +572,10 @@ static struct command_result *json_waitanyinvoice(struct command *cmd, wallet_invoice_waitany(cmd, wallet, *pay_index, &wait_on_invoice, (void*) cmd); - return command_its_complicated(); + return command_its_complicated("wallet_invoice_waitany might complete" + " immediately, but we also call it as a" + " callback so plumbing through the return" + " is non-trivial."); } static const struct json_command waitanyinvoice_command = { @@ -616,7 +619,8 @@ static struct command_result *json_waitinvoice(struct command *cmd, fixme_ignore(command_still_pending(cmd)); wallet_invoice_waitone(cmd, wallet, i, &wait_on_invoice, (void *) cmd); - return command_its_complicated(); + return command_its_complicated("wallet_invoice_waitone might" + " complete immediately"); } } diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 43d3d956c..21733af2a 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -57,7 +57,8 @@ struct command_result *command_param_failed(void) return ¶m_failed; } -struct command_result *command_its_complicated(void) +struct command_result *command_its_complicated(const char *relationship_details + UNNEEDED) { return &unknown; } diff --git a/lightningd/jsonrpc.h b/lightningd/jsonrpc.h index 2cf31631d..120e5d812 100644 --- a/lightningd/jsonrpc.h +++ b/lightningd/jsonrpc.h @@ -127,7 +127,7 @@ static inline void fixme_ignore(const struct command_result *res) } /* FIXME: For the few cases where return value is indeterminate */ -struct command_result *command_its_complicated(void); +struct command_result *command_its_complicated(const char *why); /** * Create a new jsonrpc to wrap all related information. diff --git a/lightningd/pay.c b/lightningd/pay.c index 2a84091aa..bd798453b 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -1013,7 +1013,8 @@ static struct command_result *json_sendpay(struct command *cmd, description, &json_sendpay_on_resolve, cmd)) return command_still_pending(cmd); - return command_its_complicated(); + return command_its_complicated("send_payment is called in multiple paths," + " patching return value through is hard"); } static const struct json_command sendpay_command = { @@ -1044,7 +1045,9 @@ static struct command_result *json_waitsendpay(struct command *cmd, return command_param_failed(); if (!wait_payment(cmd, cmd->ld, rhash, &json_waitsendpay_on_resolve, cmd)) - return command_its_complicated(); + return command_its_complicated("wait_payment called in multiple" + " paths, patching return value" + " through is hard"); if (timeout) new_reltimer(&cmd->ld->timers, cmd, time_from_sec(*timeout), diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 39bf95b53..6d16f4c83 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -47,20 +47,24 @@ struct command_result *command_fail(struct command *cmd UNNEEDED, int code UNNEE { fprintf(stderr, "command_fail called!\n"); abort(); } /* Generated stub for command_failed */ struct command_result *command_failed(struct command *cmd UNNEEDED, - struct json_stream *result UNNEEDED) + struct json_stream *result) + { fprintf(stderr, "command_failed called!\n"); abort(); } /* Generated stub for command_its_complicated */ -struct command_result *command_its_complicated(void) +struct command_result *command_its_complicated(const char *why UNNEEDED) { fprintf(stderr, "command_its_complicated called!\n"); abort(); } /* Generated stub for command_param_failed */ struct command_result *command_param_failed(void) + { fprintf(stderr, "command_param_failed called!\n"); abort(); } /* Generated stub for command_still_pending */ -struct command_result *command_still_pending(struct command *cmd UNNEEDED) +struct command_result *command_still_pending(struct command *cmd) + { fprintf(stderr, "command_still_pending called!\n"); abort(); } /* Generated stub for command_success */ struct command_result *command_success(struct command *cmd UNNEEDED, - struct json_stream *response UNNEEDED) + struct json_stream *response) + { fprintf(stderr, "command_success called!\n"); abort(); } /* Generated stub for connect_succeeded */ void connect_succeeded(struct lightningd *ld UNNEEDED, const struct pubkey *id UNNEEDED) diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index e588fd05a..85a06467d 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -55,18 +55,18 @@ struct command_result *command_fail(struct command *cmd UNNEEDED, int code UNNEE const char *fmt UNNEEDED, ...) { fprintf(stderr, "command_fail called!\n"); abort(); } -/* Generated stub for command_its_complicated */ -struct command_result *command_its_complicated(void) -{ fprintf(stderr, "command_its_complicated called!\n"); abort(); } /* Generated stub for command_param_failed */ struct command_result *command_param_failed(void) + { fprintf(stderr, "command_param_failed called!\n"); abort(); } /* Generated stub for command_still_pending */ -struct command_result *command_still_pending(struct command *cmd UNNEEDED) +struct command_result *command_still_pending(struct command *cmd) + { fprintf(stderr, "command_still_pending called!\n"); abort(); } /* Generated stub for command_success */ struct command_result *command_success(struct command *cmd UNNEEDED, - struct json_stream *response UNNEEDED) + struct json_stream *response) + { fprintf(stderr, "command_success called!\n"); abort(); } /* Generated stub for connect_succeeded */ void connect_succeeded(struct lightningd *ld UNNEEDED, const struct pubkey *id UNNEEDED)