Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightningd/: Hooks now support a consistent interface for 'no operation'. #3475

Merged
merged 2 commits into from
Feb 4, 2020

Conversation

ZmnSCPxj
Copy link
Collaborator

Changelog-Changed: The hooks db_write, invoice_payment, and rpc_command now accept { "result": "continue" } to mean "do default action", in addition to true (db_write), {} (invoice_payment), and {"continue": true} (rpc_command). Eventually the older "default" indicators will be deprecated, but for now they will be supported, but logged as UNUSUAL level.

Copy link
Collaborator

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a missing return.

Also I think changing test plugins to reflect that would be good(edit: necessary as Travis passed otherwise).
I used darosior@cd329fa for testing if you want to cherry-pick.

lightningd/jsonrpc.c Show resolved Hide resolved
Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just needs a compilation guard and implementation of the --deprecated-apis CLI option, so plugins can be tested against them 🙂

For reference github.com/lightningd/plugins tests with --deprecated-apis=false, so we can detect breakage early on.

lightningd/invoice.c Outdated Show resolved Hide resolved
@ZmnSCPxj
Copy link
Collaborator Author

ZmnSCPxj commented Feb 3, 2020

Deprecated old APIs, fixed code, added test from @darosior, surround with COMPAT_V080 as per @cdecker .

@ZmnSCPxj
Copy link
Collaborator Author

ZmnSCPxj commented Feb 3, 2020

changed a few more test plugin hooks to use the new syntax.

@cdecker
Copy link
Member

cdecker commented Feb 3, 2020

Seems some headers got jumbled up

if [ x"`LC_ALL=C ls common/*.h | grep -v ^common/gen_`" != x"`echo common/addr.h common/amount.h common/base32.h common/base64.h common/bech32.h common/bech32_util.h common/bigsize.h common/bip32.h common/bolt11.h common/channel_config.h common/close_tx.h common/configdir.h common/crypto_state.h common/crypto_sync.h common/cryptomsg.h common/daemon.h common/daemon_conn.h common/decode_array.h common/derive_basepoints.h common/dev_disconnect.h common/features.h common/fee_states.h common/funding_tx.h common/gossip_rcvd_filter.h common/gossip_store.h common/hash_u5.h common/htlc_state.h common/htlc_trim.h common/htlc_tx.h common/htlc_wire.h common/initial_channel.h common/initial_commit_tx.h common/io_lock.h common/json.h common/json_helpers.h common/json_tok.h common/key_derive.h common/keyset.h common/memleak.h common/msg_queue.h common/node_id.h common/onion.h common/onionreply.h common/param.h common/per_peer_state.h common/peer_billboard.h common/peer_failed.h common/permute_tx.h common/ping.h common/pseudorand.h common/read_peer_msg.h common/socket_close.h common/sphinx.h common/status.h common/status_wire.h common/subdaemon.h common/timeout.h common/type_to_string.h common/utils.h common/utxo.h common/version.h common/wallet.h common/wallet_tx.h common/wireaddr.h common/wire_error.h common/withdraw_tx.h common/errcode.h common/gossip_constants.h common/htlc.h common/json_command.h common/jsonrpc_errors.h common/overflows.h common/status_levels.h | tr ' ' '\n' | LC_ALL=C sort`" ]; then echo COMMON_HEADERS_NOGEN incorrect; exit 1; fi
tests/plugins/hold_invoice.py:14:21: E203 whitespace before ':'
Makefile:314: recipe for target 'check-python' failed
make: *** [check-python] Error 1

And this seems to be related to COMPAT=0:

lightningd/jsonrpc.c: In function ‘rpc_command_hook_callback’:
lightningd/jsonrpc.c:673:7: error: unused variable ‘exec’ [-Werror=unused-variable]
  bool exec;
       ^~~~
lightningd/jsonrpc.c:670:50: error: unused variable ‘tok_continue’ [-Werror=unused-variable]
  const jsmntok_t *tok, *params, *custom_return, *tok_continue;
                                                  ^~~~~~~~~~~~

Copy link
Collaborator

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a tiny rebase otherwise ACK 80377c7

ZmnSCPxj and others added 2 commits February 3, 2020 23:42
…on'.

Changelog-Changed: The hooks `db_write`, `invoice_payment`, and `rpc_command` now accept `{ "result": "continue" }` to mean "do default action", in addition to `true` (`db_write`), `{}` (`invoice_payment`), and `{"continue": true}` (`rpc_command`). The older "default" indicators are now deprecated and are now recognized only if `--deprecated-apis` is set.
@ZmnSCPxj
Copy link
Collaborator Author

ZmnSCPxj commented Feb 4, 2020

ACK 68cab35

Re-applying @darosior ACK

@ZmnSCPxj ZmnSCPxj merged commit 9030e5d into ElementsProject:master Feb 4, 2020
@ZmnSCPxj ZmnSCPxj deleted the hook-consistency branch February 4, 2020 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants