Modern param style for chaintopology.c, ...

connect_control.c, dev_ping.c, gossip_control.c, invoice.c.

This converts about 50% of all calls of `json_get_params` to `param`.

After trying (and failing) to squash and rebase #1682 I just made a new branch
from a patch file and closed #1682.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
Mark Beckwith
2018-07-16 15:48:38 -05:00
committed by Christian Decker
parent 232b330284
commit b876c601a6
5 changed files with 114 additions and 317 deletions

View File

@@ -9,6 +9,7 @@
#include <lightningd/jsonrpc_errors.h>
#include <lightningd/lightningd.h>
#include <lightningd/log.h>
#include <lightningd/param.h>
#include <lightningd/subd.h>
struct connect {
@@ -80,7 +81,8 @@ void gossip_connect_result(struct lightningd *ld, const u8 *msg)
static void json_connect(struct command *cmd,
const char *buffer, const jsmntok_t *params)
{
jsmntok_t *hosttok, *porttok, *idtok;
const jsmntok_t *hosttok, *porttok;
jsmntok_t *idtok;
struct pubkey id;
char *id_str;
char *atptr;
@@ -90,13 +92,12 @@ static void json_connect(struct command *cmd,
u8 *msg;
const char *err_msg;
if (!json_get_params(cmd, buffer, params,
"id", &idtok,
"?host", &hosttok,
"?port", &porttok,
NULL)) {
if (!param(cmd, buffer, params,
p_req("id", json_tok_tok, (const jsmntok_t **) &idtok),
p_opt_tok("host", &hosttok),
p_opt_tok("port", &porttok),
NULL))
return;
}
/* Check for id@addrport form */
id_str = tal_strndup(cmd, buffer + idtok->start,