2018-03-16 04:45:08 +01:00
|
|
|
/* lightningd/json.h
|
|
|
|
* Helpers for outputting JSON results that are specific only for
|
|
|
|
* lightningd.
|
|
|
|
*/
|
|
|
|
#ifndef LIGHTNING_LIGHTNINGD_JSON_H
|
|
|
|
#define LIGHTNING_LIGHTNINGD_JSON_H
|
|
|
|
#include "config.h"
|
2020-07-07 22:50:21 +02:00
|
|
|
#include <bitcoin/feerate.h>
|
2019-06-08 10:58:08 +02:00
|
|
|
#include <bitcoin/privkey.h>
|
2018-08-28 22:46:32 +02:00
|
|
|
#include <ccan/short_types/short_types.h>
|
2018-10-19 03:17:48 +02:00
|
|
|
#include <ccan/tal/tal.h>
|
2018-03-16 04:45:08 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
2018-08-13 18:16:41 +02:00
|
|
|
#include <stdint.h>
|
2018-03-16 04:45:08 +01:00
|
|
|
|
|
|
|
#define JSMN_STRICT 1
|
|
|
|
# include <external/jsmn/jsmn.h>
|
|
|
|
|
|
|
|
struct bitcoin_txid;
|
2018-11-20 02:46:32 +01:00
|
|
|
struct chainparams;
|
2018-04-30 14:54:39 +02:00
|
|
|
struct channel_id;
|
2018-08-10 17:00:34 +02:00
|
|
|
struct command;
|
2019-06-12 02:38:54 +02:00
|
|
|
struct json_escape;
|
2018-03-16 04:45:08 +01:00
|
|
|
struct pubkey;
|
common/node_id: new type.
Node ids are pubkeys, but we only use them as pubkeys for routing and checking
gossip messages. So we're packing and unpacking them constantly, and wasting
some space and time.
This introduces a new type, explicitly the SEC1 compressed encoding
(33 bytes). We ensure its validity when we load from the db, or get it
from JSON. We still use 'struct pubkey' for peer messages, which checks
validity.
Results from 5 runs, min-max(mean +/- stddev):
store_load_msec,vsz_kb,store_rewrite_sec,listnodes_sec,listchannels_sec,routing_sec,peer_write_all_sec
39475-39572(39518+/-36),2880732,41.150000-41.390000(41.298+/-0.085),2.260000-2.550000(2.336+/-0.11),44.390000-65.150000(58.648+/-7.5),32.740000-33.020000(32.89+/-0.093),44.130000-45.090000(44.566+/-0.32)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-08 08:34:06 +02:00
|
|
|
struct node_id;
|
2018-03-16 04:45:08 +01:00
|
|
|
struct short_channel_id;
|
|
|
|
|
2018-12-16 05:50:06 +01:00
|
|
|
struct command_result *param_pubkey(struct command *cmd, const char *name,
|
|
|
|
const char *buffer, const jsmntok_t *tok,
|
|
|
|
struct pubkey **pubkey);
|
common/node_id: new type.
Node ids are pubkeys, but we only use them as pubkeys for routing and checking
gossip messages. So we're packing and unpacking them constantly, and wasting
some space and time.
This introduces a new type, explicitly the SEC1 compressed encoding
(33 bytes). We ensure its validity when we load from the db, or get it
from JSON. We still use 'struct pubkey' for peer messages, which checks
validity.
Results from 5 runs, min-max(mean +/- stddev):
store_load_msec,vsz_kb,store_rewrite_sec,listnodes_sec,listchannels_sec,routing_sec,peer_write_all_sec
39475-39572(39518+/-36),2880732,41.150000-41.390000(41.298+/-0.085),2.260000-2.550000(2.336+/-0.11),44.390000-65.150000(58.648+/-7.5),32.740000-33.020000(32.89+/-0.093),44.130000-45.090000(44.566+/-0.32)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-08 08:34:06 +02:00
|
|
|
|
2018-12-16 05:50:06 +01:00
|
|
|
struct command_result *param_short_channel_id(struct command *cmd,
|
|
|
|
const char *name,
|
|
|
|
const char *buffer,
|
|
|
|
const jsmntok_t *tok,
|
|
|
|
struct short_channel_id **scid);
|
2018-03-16 04:45:08 +01:00
|
|
|
|
2018-08-27 07:11:39 +02:00
|
|
|
/* Extract a feerate style. */
|
2018-12-16 05:50:06 +01:00
|
|
|
struct command_result *param_feerate_style(struct command *cmd,
|
|
|
|
const char *name,
|
|
|
|
const char *buffer,
|
|
|
|
const jsmntok_t *tok,
|
|
|
|
enum feerate_style **style);
|
2018-08-27 07:11:39 +02:00
|
|
|
|
|
|
|
const char *json_feerate_style_name(enum feerate_style style);
|
|
|
|
|
2018-08-28 22:46:32 +02:00
|
|
|
/* Extract a feerate with optional style suffix. */
|
2018-12-16 05:50:06 +01:00
|
|
|
struct command_result *param_feerate(struct command *cmd, const char *name,
|
|
|
|
const char *buffer, const jsmntok_t *tok,
|
|
|
|
u32 **feerate);
|
2018-08-28 22:46:32 +02:00
|
|
|
|
2018-04-30 14:54:39 +02:00
|
|
|
bool json_tok_channel_id(const char *buffer, const jsmntok_t *tok,
|
|
|
|
struct channel_id *cid);
|
2018-03-22 11:36:25 +01:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_JSON_H */
|