mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-19 21:14:38 +01:00
gossmap: don't spew to stderr, include counter for callers.
Fixes: #4722 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: Plugins: don't drop complaints about silly channels to stderr.
This commit is contained in:
@@ -462,12 +462,18 @@ static struct command_result *sendonionmsg_done(struct command *cmd,
|
||||
|
||||
static void init_gossmap(struct plugin *plugin)
|
||||
{
|
||||
size_t num_cupdates_rejected;
|
||||
global_gossmap
|
||||
= notleak_with_children(gossmap_load(NULL,
|
||||
GOSSIP_STORE_FILENAME));
|
||||
GOSSIP_STORE_FILENAME,
|
||||
&num_cupdates_rejected));
|
||||
if (!global_gossmap)
|
||||
plugin_err(plugin, "Could not load gossmap %s: %s",
|
||||
GOSSIP_STORE_FILENAME, strerror(errno));
|
||||
if (num_cupdates_rejected)
|
||||
plugin_log(plugin, LOG_DBG,
|
||||
"gossmap ignored %zu channel updates",
|
||||
num_cupdates_rejected);
|
||||
}
|
||||
|
||||
static struct gossmap *get_gossmap(struct plugin *plugin)
|
||||
@@ -475,7 +481,7 @@ static struct gossmap *get_gossmap(struct plugin *plugin)
|
||||
if (!global_gossmap)
|
||||
init_gossmap(plugin);
|
||||
else
|
||||
gossmap_refresh(global_gossmap);
|
||||
gossmap_refresh(global_gossmap, NULL);
|
||||
return global_gossmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,18 @@ static struct gossmap *global_gossmap;
|
||||
|
||||
static void init_gossmap(struct plugin *plugin)
|
||||
{
|
||||
size_t num_channel_updates_rejected;
|
||||
global_gossmap
|
||||
= notleak_with_children(gossmap_load(NULL,
|
||||
GOSSIP_STORE_FILENAME));
|
||||
GOSSIP_STORE_FILENAME,
|
||||
&num_channel_updates_rejected));
|
||||
if (!global_gossmap)
|
||||
plugin_err(plugin, "Could not load gossmap %s: %s",
|
||||
GOSSIP_STORE_FILENAME, strerror(errno));
|
||||
if (num_channel_updates_rejected)
|
||||
plugin_log(plugin, LOG_DBG,
|
||||
"gossmap ignored %zu channel updates",
|
||||
num_channel_updates_rejected);
|
||||
}
|
||||
|
||||
struct gossmap *get_gossmap(struct plugin *plugin)
|
||||
@@ -30,7 +36,7 @@ struct gossmap *get_gossmap(struct plugin *plugin)
|
||||
if (!global_gossmap)
|
||||
init_gossmap(plugin);
|
||||
else
|
||||
gossmap_refresh(global_gossmap);
|
||||
gossmap_refresh(global_gossmap, NULL);
|
||||
return global_gossmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ int main(void)
|
||||
assert(write(store_fd, &gossip_version, sizeof(gossip_version))
|
||||
== sizeof(gossip_version));
|
||||
|
||||
gossmap = gossmap_load(tmpctx, gossipfilename);
|
||||
gossmap = gossmap_load(tmpctx, gossipfilename, NULL);
|
||||
|
||||
for (size_t i = 0; i < NUM_NODES; i++) {
|
||||
struct privkey tmp;
|
||||
@@ -384,7 +384,7 @@ int main(void)
|
||||
1 << i);
|
||||
}
|
||||
|
||||
assert(gossmap_refresh(gossmap));
|
||||
assert(gossmap_refresh(gossmap, NULL));
|
||||
for (size_t i = ROUTING_MAX_HOPS; i > 2; i--) {
|
||||
struct gossmap_node *dst, *src;
|
||||
struct route_hop *r;
|
||||
|
||||
@@ -27,7 +27,7 @@ static struct plugin *plugin;
|
||||
/* We load this on demand, since we can start before gossipd. */
|
||||
static struct gossmap *get_gossmap(void)
|
||||
{
|
||||
gossmap_refresh(global_gossmap);
|
||||
gossmap_refresh(global_gossmap, NULL);
|
||||
return global_gossmap;
|
||||
}
|
||||
|
||||
@@ -687,17 +687,24 @@ done:
|
||||
static const char *init(struct plugin *p,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
{
|
||||
size_t num_cupdates_rejected;
|
||||
|
||||
plugin = p;
|
||||
rpc_scan(p, "getinfo",
|
||||
take(json_out_obj(NULL, NULL, NULL)),
|
||||
"{id:%}", JSON_SCAN(json_to_node_id, &local_id));
|
||||
|
||||
global_gossmap = notleak_with_children(gossmap_load(NULL,
|
||||
GOSSIP_STORE_FILENAME));
|
||||
GOSSIP_STORE_FILENAME,
|
||||
&num_cupdates_rejected));
|
||||
if (!global_gossmap)
|
||||
plugin_err(plugin, "Could not load gossmap %s: %s",
|
||||
GOSSIP_STORE_FILENAME, strerror(errno));
|
||||
|
||||
if (num_cupdates_rejected)
|
||||
plugin_log(plugin, LOG_DBG,
|
||||
"gossmap ignored %zu channel updates",
|
||||
num_cupdates_rejected);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user