If there are pending channel announcements, they'll look like a leak unless we scan into the maps. ``` lightningd-2 2025-05-01T07:27:03.922Z **BROKEN** gossipd: MEMLEAK: 0x60d000000478 lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: label=gossipd/gossmap_manage.c:595:struct pending_cannounce lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: alloc: lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/tal/tal.c:488 (tal_alloc_) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossmap_manage.c:595 (gossmap_manage_channel_announcement) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossipd.c:205 (handle_recv_gossip) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossipd.c:300 (connectd_req) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/common/daemon_conn.c:35 (handle_read) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:60 (next_plan) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:422 (do_plan) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:439 (io_ready) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/poll.c:455 (io_loop) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossipd.c:660 (main) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: ../sysdeps/nptl/libc_start_call_main.h:58 (__libc_start_call_main) lightningd-2 2025-05-01T07:27:03.924Z **BROKEN** gossipd: ../csu/libc-start.c:392 (__libc_start_main_impl) lightningd-2 2025-05-01T07:27:03.924Z **BROKEN** gossipd: parents: lightningd-2 2025-05-01T07:27:03.924Z **BROKEN** gossipd: gossipd/gossmap_manage.c:475:struct gossmap_manage ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
118 lines
3.8 KiB
C
118 lines
3.8 KiB
C
#ifndef LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H
|
|
#define LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H
|
|
#include "config.h"
|
|
|
|
struct daemon;
|
|
struct gossmap_manage;
|
|
struct chan_dying;
|
|
|
|
struct gossmap_manage *gossmap_manage_new(const tal_t *ctx,
|
|
struct daemon *daemon);
|
|
|
|
/**
|
|
* gossmap_manage_channel_announcement: process an incoming channel_announcement
|
|
* @ctx: tal context for return string
|
|
* @gm: the gossmap_manage context
|
|
* @announce: the channel_announcement message
|
|
* @source_peer: peer who sent this (NULL if it's from lightningd)
|
|
* @known_amount: if non-NULL, do not ask lightningd to look up UTXO.
|
|
*
|
|
* Returns an error string if it wasn't redundant or included. Lightningd
|
|
* suppresses lookups if it generated the announcement, partially because it's
|
|
* redundant, but also because in our tests the UTXO is often spent by the time
|
|
* it processes the lookup!
|
|
*/
|
|
const char *gossmap_manage_channel_announcement(const tal_t *ctx,
|
|
struct gossmap_manage *gm,
|
|
const u8 *announce TAKES,
|
|
const struct node_id *source_peer TAKES,
|
|
const struct amount_sat *known_amount);
|
|
|
|
|
|
/**
|
|
* gossmap_manage_handle_get_txout_reply: process a txout reply from lightningd
|
|
* @gm: the gossmap_manage context
|
|
* @msg: the message
|
|
*
|
|
* Since handle_channel_announcement asks lightning for utxos,
|
|
* it gets called back here.
|
|
*/
|
|
void gossmap_manage_handle_get_txout_reply(struct gossmap_manage *gm, const u8 *msg);
|
|
|
|
/**
|
|
* gossmap_manage_channel_update: process an incoming channel_update
|
|
* @ctx: tal context for return string
|
|
* @gm: the gossmap_manage context
|
|
* @update: the channel_update message
|
|
* @source_peer: optional peer who sent this
|
|
*
|
|
* Returns an error string if it wasn't redundant or included.
|
|
*/
|
|
const char *gossmap_manage_channel_update(const tal_t *ctx,
|
|
struct gossmap_manage *gm,
|
|
const u8 *update TAKES,
|
|
const struct node_id *source_peer TAKES);
|
|
|
|
/**
|
|
* gossmap_manage_node_announcement: process an incoming node_announcement
|
|
* @ctx: tal context for return string allocation
|
|
* @gm: the gossmap_manage context
|
|
* @node_announcement: the node_announcement message
|
|
* @source_peer: optional peer who sent this
|
|
*
|
|
* Returns an error string if it wasn't redundant or included.
|
|
*/
|
|
const char *gossmap_manage_node_announcement(const tal_t *ctx,
|
|
struct gossmap_manage *gm,
|
|
const u8 *node_announcement TAKES,
|
|
const struct node_id *source_peer TAKES);
|
|
|
|
/**
|
|
* gossmap_manage_new_block: handle block height update.
|
|
* @gm: the gossmap_manage context
|
|
* @new_blockheight: the new blockheight
|
|
*/
|
|
void gossmap_manage_new_block(struct gossmap_manage *gm, u32 new_blockheight);
|
|
|
|
/**
|
|
* gossmap_manage_channel_spent: handle an UTXO being spent
|
|
* @gm: the gossmap_manage context
|
|
* @blockheight: the blockheight it was spent at
|
|
* @scid: the short_channel_id
|
|
*
|
|
* lightningd tells us all the possible UTXOs spent every block: most
|
|
* don't match channels.
|
|
*/
|
|
void gossmap_manage_channel_spent(struct gossmap_manage *gm,
|
|
u32 blockheight,
|
|
struct short_channel_id scid);
|
|
|
|
/**
|
|
* gossmap_manage_get_gossmap: get the (refreshed!) gossmap
|
|
* @gm: the gossmap_manage context
|
|
*/
|
|
struct gossmap *gossmap_manage_get_gossmap(struct gossmap_manage *gm);
|
|
|
|
/**
|
|
* gossmap_manage_tell_lightningd_locals: tell lightningd our latest updates.
|
|
* @daemon: the gossip daemon
|
|
* @gm: the gossmap_manage context
|
|
*
|
|
* Done before we reply to gossipd_init.
|
|
*/
|
|
void gossmap_manage_tell_lightningd_locals(struct daemon *daemon,
|
|
struct gossmap_manage *gm);
|
|
|
|
/**
|
|
* gossmap_manage_populated - do we have some gossip?
|
|
* @gm: the gossmap_manage context.
|
|
*
|
|
*
|
|
* The seeker uses this if we're at startup and want complete gossip.
|
|
*/
|
|
bool gossmap_manage_populated(const struct gossmap_manage *gm);
|
|
|
|
/* For memleak to see inside of maps */
|
|
void gossmap_manage_memleak(struct htable *memtable, const struct gossmap_manage *gm);
|
|
#endif /* LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H */
|