mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-05 23:24:21 +01:00
libplugin: don't spew datastore errors to LOG_DEBUG.
People get upset, especially as our "not found" error can be a bit hard to read! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> See-also: #5990
This commit is contained in:
committed by
Alex Myers
parent
dd9400df99
commit
70aee52903
@@ -574,8 +574,11 @@ static const char *init(struct plugin *p,
|
||||
|
||||
cleantimer = plugin_timer(p, time_from_sec(cycle_seconds), do_clean_timer, NULL);
|
||||
|
||||
/* We don't care if this fails (it usually does, since entries
|
||||
* don't exist! */
|
||||
for (enum subsystem i = 0; i < NUM_SUBSYSTEM; i++) {
|
||||
rpc_scan_datastore_str(plugin, datastore_path(tmpctx, i, "num"),
|
||||
rpc_scan_datastore_str(tmpctx, plugin,
|
||||
datastore_path(tmpctx, i, "num"),
|
||||
JSON_SCAN(json_to_u64, &total_cleaned[i]));
|
||||
}
|
||||
|
||||
|
||||
@@ -989,6 +989,7 @@ static const char *init(struct plugin *p,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
{
|
||||
struct secret rune_secret;
|
||||
const char *err;
|
||||
|
||||
outgoing_commands = tal_arr(p, struct commando *, 0);
|
||||
incoming_commands = tal_arr(p, struct commando *, 0);
|
||||
@@ -1000,13 +1001,16 @@ static const char *init(struct plugin *p,
|
||||
#endif
|
||||
|
||||
rune_counter = tal(p, u64);
|
||||
if (!rpc_scan_datastore_str(plugin, "commando/rune_counter",
|
||||
JSON_SCAN(json_to_u64, rune_counter)))
|
||||
/* If this fails, it probably doesn't exist */
|
||||
err = rpc_scan_datastore_str(tmpctx, plugin, "commando/rune_counter",
|
||||
JSON_SCAN(json_to_u64, rune_counter));
|
||||
if (err)
|
||||
rune_counter = tal_free(rune_counter);
|
||||
|
||||
/* Old python commando used to store secret */
|
||||
if (!rpc_scan_datastore_hex(plugin, "commando/secret",
|
||||
JSON_SCAN(json_to_secret, &rune_secret))) {
|
||||
err = rpc_scan_datastore_hex(tmpctx, plugin, "commando/secret",
|
||||
JSON_SCAN(json_to_secret, &rune_secret));
|
||||
if (err) {
|
||||
rpc_scan(plugin, "makesecret",
|
||||
/* $ i commando
|
||||
* 99 0x63 0143 0b1100011 'c'
|
||||
|
||||
@@ -627,14 +627,14 @@ static void json_add_keypath(struct json_out *jout, const char *fieldname, const
|
||||
json_out_end(jout, ']');
|
||||
}
|
||||
|
||||
static bool rpc_scan_datastore(struct plugin *plugin,
|
||||
const char *path,
|
||||
const char *hex_or_string,
|
||||
va_list ap)
|
||||
static const char *rpc_scan_datastore(const tal_t *ctx,
|
||||
struct plugin *plugin,
|
||||
const char *path,
|
||||
const char *hex_or_string,
|
||||
va_list ap)
|
||||
{
|
||||
const char *guide;
|
||||
struct json_out *params;
|
||||
const char *err;
|
||||
|
||||
params = json_out_new(NULL);
|
||||
json_out_start(params, NULL, '{');
|
||||
@@ -643,37 +643,35 @@ static bool rpc_scan_datastore(struct plugin *plugin,
|
||||
json_out_finished(params);
|
||||
|
||||
guide = tal_fmt(tmpctx, "{datastore:[0:{%s:%%}]}", hex_or_string);
|
||||
/* FIXME: Could be some other error, but that's probably a caller bug! */
|
||||
err = rpc_scan_core(tmpctx, plugin, "listdatastore", take(params), guide, ap);
|
||||
if (!err)
|
||||
return true;
|
||||
plugin_log(plugin, LOG_DBG, "listdatastore error %s: %s", path, err);
|
||||
return false;
|
||||
return rpc_scan_core(ctx, plugin, "listdatastore", take(params),
|
||||
guide, ap);
|
||||
}
|
||||
|
||||
bool rpc_scan_datastore_str(struct plugin *plugin,
|
||||
const char *path,
|
||||
...)
|
||||
const char *rpc_scan_datastore_str(const tal_t *ctx,
|
||||
struct plugin *plugin,
|
||||
const char *path,
|
||||
...)
|
||||
{
|
||||
bool ret;
|
||||
const char *ret;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, path);
|
||||
ret = rpc_scan_datastore(plugin, path, "string", ap);
|
||||
ret = rpc_scan_datastore(ctx, plugin, path, "string", ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* This variant scans the hex encoding, not the string */
|
||||
bool rpc_scan_datastore_hex(struct plugin *plugin,
|
||||
const char *path,
|
||||
...)
|
||||
const char *rpc_scan_datastore_hex(const tal_t *ctx,
|
||||
struct plugin *plugin,
|
||||
const char *path,
|
||||
...)
|
||||
{
|
||||
bool ret;
|
||||
const char *ret;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, path);
|
||||
ret = rpc_scan_datastore(plugin, path, "hex", ap);
|
||||
ret = rpc_scan_datastore(ctx, plugin, path, "hex", ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -310,17 +310,19 @@ void rpc_scan(struct plugin *plugin,
|
||||
const char *guide,
|
||||
...);
|
||||
|
||||
/* Helper to scan datastore: can only be used in init callback. *
|
||||
Returns false if field does not exist. * path is /-separated. Final
|
||||
arg is JSON_SCAN or JSON_SCAN_TAL.
|
||||
/* Helper to scan datastore: can only be used in init callback. Returns error
|
||||
* msg (usually meaning field does not exist), or NULL on success. path is
|
||||
* /-separated. Final arg is JSON_SCAN or JSON_SCAN_TAL.
|
||||
*/
|
||||
bool rpc_scan_datastore_str(struct plugin *plugin,
|
||||
const char *path,
|
||||
...);
|
||||
const char *rpc_scan_datastore_str(const tal_t *ctx,
|
||||
struct plugin *plugin,
|
||||
const char *path,
|
||||
...);
|
||||
/* This variant scans the hex encoding, not the string */
|
||||
bool rpc_scan_datastore_hex(struct plugin *plugin,
|
||||
const char *path,
|
||||
...);
|
||||
const char *rpc_scan_datastore_hex(const tal_t *ctx,
|
||||
struct plugin *plugin,
|
||||
const char *path,
|
||||
...);
|
||||
|
||||
/* This sets batching of database commitments */
|
||||
void rpc_enable_batching(struct plugin *plugin);
|
||||
|
||||
Reference in New Issue
Block a user