mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
libplugin don't expose the plugin struct
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
static u64 cycle_seconds = 0, expired_by = 86400;
|
static u64 cycle_seconds = 0, expired_by = 86400;
|
||||||
static struct plugin_timer *cleantimer;
|
static struct plugin_timer *cleantimer;
|
||||||
static struct rpc_conn *rpc;
|
|
||||||
|
|
||||||
static struct command_result *do_clean(struct plugin *p);
|
static struct command_result *do_clean(struct plugin *p);
|
||||||
|
|
||||||
@@ -69,8 +68,6 @@ static struct command_result *json_autocleaninvoice(struct command *cmd,
|
|||||||
static void init(struct plugin *p,
|
static void init(struct plugin *p,
|
||||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||||
{
|
{
|
||||||
rpc = p->rpc_conn;
|
|
||||||
|
|
||||||
if (cycle_seconds) {
|
if (cycle_seconds) {
|
||||||
plugin_log(p, LOG_INFORM, "autocleaning every %"PRIu64" seconds", cycle_seconds);
|
plugin_log(p, LOG_INFORM, "autocleaning every %"PRIu64" seconds", cycle_seconds);
|
||||||
cleantimer = plugin_timer(p, time_from_sec(cycle_seconds),
|
cleantimer = plugin_timer(p, time_from_sec(cycle_seconds),
|
||||||
|
|||||||
@@ -51,6 +51,57 @@ struct rpc_conn {
|
|||||||
MEMBUF(char) mb;
|
MEMBUF(char) mb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct plugin {
|
||||||
|
/* lightningd interaction */
|
||||||
|
struct io_conn *stdin_conn;
|
||||||
|
struct io_conn *stdout_conn;
|
||||||
|
|
||||||
|
/* To read from lightningd */
|
||||||
|
char *buffer;
|
||||||
|
size_t used, len_read;
|
||||||
|
|
||||||
|
/* To write to lightningd */
|
||||||
|
struct json_stream **js_arr;
|
||||||
|
|
||||||
|
/* Asynchronous RPC interaction */
|
||||||
|
struct io_conn *io_rpc_conn;
|
||||||
|
struct json_stream **rpc_js_arr;
|
||||||
|
char *rpc_buffer;
|
||||||
|
size_t rpc_used, rpc_len_read;
|
||||||
|
/* Tracking async RPC requests */
|
||||||
|
UINTMAP(struct out_req *) out_reqs;
|
||||||
|
u64 next_outreq_id;
|
||||||
|
|
||||||
|
/* Synchronous RPC interaction */
|
||||||
|
struct rpc_conn *rpc_conn;
|
||||||
|
|
||||||
|
/* Plugin informations */
|
||||||
|
enum plugin_restartability restartability;
|
||||||
|
const struct plugin_command *commands;
|
||||||
|
size_t num_commands;
|
||||||
|
const struct plugin_notification *notif_subs;
|
||||||
|
size_t num_notif_subs;
|
||||||
|
const struct plugin_hook *hook_subs;
|
||||||
|
size_t num_hook_subs;
|
||||||
|
struct plugin_option *opts;
|
||||||
|
|
||||||
|
/* Anything special to do at init ? */
|
||||||
|
void (*init)(struct plugin *p,
|
||||||
|
const char *buf, const jsmntok_t *);
|
||||||
|
/* Has the manifest been sent already ? */
|
||||||
|
bool manifested;
|
||||||
|
/* Has init been received ? */
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
|
/* Map from json command names to usage strings: we don't put this inside
|
||||||
|
* struct json_command as it's good practice to have those const. */
|
||||||
|
STRMAP(const char *) usagemap;
|
||||||
|
/* Timers */
|
||||||
|
struct timers timers;
|
||||||
|
size_t in_timer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* command_result is mainly used as a compile-time check to encourage you
|
/* command_result is mainly used as a compile-time check to encourage you
|
||||||
* to return as soon as you get one (and not risk use-after-free of command).
|
* to return as soon as you get one (and not risk use-after-free of command).
|
||||||
* Here we use two values: complete (cmd freed) and pending (still going) */
|
* Here we use two values: complete (cmd freed) and pending (still going) */
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <common/status_levels.h>
|
#include <common/status_levels.h>
|
||||||
|
|
||||||
struct json_out;
|
struct json_out;
|
||||||
|
struct plugin;
|
||||||
struct rpc_conn;
|
struct rpc_conn;
|
||||||
|
|
||||||
extern bool deprecated_apis;
|
extern bool deprecated_apis;
|
||||||
@@ -26,56 +27,6 @@ enum plugin_restartability {
|
|||||||
PLUGIN_RESTARTABLE
|
PLUGIN_RESTARTABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct plugin {
|
|
||||||
/* lightningd interaction */
|
|
||||||
struct io_conn *stdin_conn;
|
|
||||||
struct io_conn *stdout_conn;
|
|
||||||
|
|
||||||
/* To read from lightningd */
|
|
||||||
char *buffer;
|
|
||||||
size_t used, len_read;
|
|
||||||
|
|
||||||
/* To write to lightningd */
|
|
||||||
struct json_stream **js_arr;
|
|
||||||
|
|
||||||
/* Asynchronous RPC interaction */
|
|
||||||
struct io_conn *io_rpc_conn;
|
|
||||||
struct json_stream **rpc_js_arr;
|
|
||||||
char *rpc_buffer;
|
|
||||||
size_t rpc_used, rpc_len_read;
|
|
||||||
/* Tracking async RPC requests */
|
|
||||||
UINTMAP(struct out_req *) out_reqs;
|
|
||||||
u64 next_outreq_id;
|
|
||||||
|
|
||||||
/* Synchronous RPC interaction */
|
|
||||||
struct rpc_conn *rpc_conn;
|
|
||||||
|
|
||||||
/* Plugin informations */
|
|
||||||
enum plugin_restartability restartability;
|
|
||||||
const struct plugin_command *commands;
|
|
||||||
size_t num_commands;
|
|
||||||
const struct plugin_notification *notif_subs;
|
|
||||||
size_t num_notif_subs;
|
|
||||||
const struct plugin_hook *hook_subs;
|
|
||||||
size_t num_hook_subs;
|
|
||||||
struct plugin_option *opts;
|
|
||||||
|
|
||||||
/* Anything special to do at init ? */
|
|
||||||
void (*init)(struct plugin *p,
|
|
||||||
const char *buf, const jsmntok_t *);
|
|
||||||
/* Has the manifest been sent already ? */
|
|
||||||
bool manifested;
|
|
||||||
/* Has init been received ? */
|
|
||||||
bool initialized;
|
|
||||||
|
|
||||||
/* Map from json command names to usage strings: we don't put this inside
|
|
||||||
* struct json_command as it's good practice to have those const. */
|
|
||||||
STRMAP(const char *) usagemap;
|
|
||||||
/* Timers */
|
|
||||||
struct timers timers;
|
|
||||||
size_t in_timer;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct command {
|
struct command {
|
||||||
u64 *id;
|
u64 *id;
|
||||||
const char *methodname;
|
const char *methodname;
|
||||||
|
|||||||
Reference in New Issue
Block a user