mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
af7e641445
This looked like a test flake, but was real: ``` l1.daemon.wait_for_log("closing soon due to the funding outpoint being spent") # We won't gossip the dead channel any more (but we still propagate node_announcement). But connectd is not explicitly synced, so wait for "a bit". time.sleep(1) > assert len(get_gossip(l1)) == 2 E assert 4 == 2 ``` We can see that two channel_updates come in *after* we mark it dying: ``` gossipd: channel 103x1x0 closing soon due to the funding outpoint being spent gossipd: REPLY WIRE_GOSSIPD_NEW_BLOCKHEIGHT_REPLY with 0 fds 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Received channel_update for channel 103x1x0/0 now DISABLED 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-gossipd: Received channel_update for channel 103x1x0/1 now DISABLED ``` We should keep marking channel_updates the same way. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
120 lines
3.5 KiB
C
120 lines
3.5 KiB
C
#ifndef LIGHTNING_GOSSIPD_GOSSIP_STORE_H
|
|
#define LIGHTNING_GOSSIPD_GOSSIP_STORE_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <bitcoin/short_channel_id.h>
|
|
#include <ccan/list/list.h>
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <ccan/tal/tal.h>
|
|
#include <gossipd/routing.h>
|
|
|
|
/**
|
|
* gossip_store -- On-disk storage related information
|
|
*/
|
|
|
|
struct gossip_store;
|
|
struct routing_state;
|
|
|
|
struct gossip_store *gossip_store_new(struct routing_state *rstate);
|
|
|
|
/**
|
|
* Load the initial gossip store, if any.
|
|
*
|
|
* @param rstate The routing state to load init.
|
|
* @param gs The `gossip_store` to read from
|
|
*
|
|
* Returns the last-modified time of the store, or 0 if it was created new.
|
|
*/
|
|
u32 gossip_store_load(struct routing_state *rstate, struct gossip_store *gs);
|
|
|
|
/**
|
|
* Add a private channel_update message to the gossip_store
|
|
*/
|
|
u64 gossip_store_add_private_update(struct gossip_store *gs, const u8 *update);
|
|
|
|
/**
|
|
* Add a gossip message to the gossip_store (and optional addendum)
|
|
* @gs: gossip store
|
|
* @gossip_msg: the gossip message to insert.
|
|
* @timestamp: the timestamp for filtering of this messsage.
|
|
* @zombie: true if this channel is missing a current channel_update.
|
|
* @spam: true if this message is rate-limited and squelched to peers.
|
|
* @dying: true if this message is for a dying channel.
|
|
* @addendum: another message to append immediately after this
|
|
* (for appending amounts to channel_announcements for internal use).
|
|
*/
|
|
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg,
|
|
u32 timestamp, bool zombie, bool spam, bool dying,
|
|
const u8 *addendum);
|
|
|
|
|
|
/**
|
|
* Delete the broadcast associated with this (if any).
|
|
*
|
|
* In developer mode, checks that type is correct.
|
|
*/
|
|
void gossip_store_delete(struct gossip_store *gs,
|
|
struct broadcastable *bcast,
|
|
int type);
|
|
|
|
/**
|
|
* Mark that the channel is about to be deleted, for convenience of
|
|
* others mapping the gossip_store.
|
|
*/
|
|
void gossip_store_mark_channel_deleted(struct gossip_store *gs,
|
|
const struct short_channel_id *scid);
|
|
|
|
/*
|
|
* Marks the length field of a channel announcement with a zombie flag bit.
|
|
* This allows the channel_announcement to be retained in the store while
|
|
* waiting for channel updates to reactivate it.
|
|
*/
|
|
void gossip_store_mark_channel_zombie(struct gossip_store *gs,
|
|
struct broadcastable *bcast);
|
|
|
|
void gossip_store_mark_cupdate_zombie(struct gossip_store *gs,
|
|
struct broadcastable *bcast);
|
|
|
|
/**
|
|
* Mark this channel_announcement/channel_update as dying.
|
|
*
|
|
* We'll clean it up in 12 blocks, but this tells connectd not to gossip
|
|
* about it.
|
|
*/
|
|
void gossip_store_mark_dying(struct gossip_store *gs,
|
|
const struct broadcastable *bcast,
|
|
int type);
|
|
|
|
|
|
/**
|
|
* Direct store accessor: loads gossip msg back from store.
|
|
*
|
|
* Caller must ensure offset != 0. Never returns NULL.
|
|
*/
|
|
const u8 *gossip_store_get(const tal_t *ctx,
|
|
struct gossip_store *gs,
|
|
u64 offset);
|
|
|
|
/**
|
|
* Direct store accessor: loads private gossip msg back from store.
|
|
*
|
|
* Caller must ensure offset != 0. Never returns NULL.
|
|
*/
|
|
const u8 *gossip_store_get_private_update(const tal_t *ctx,
|
|
struct gossip_store *gs,
|
|
u64 offset);
|
|
|
|
/* Exposed for dev-compact-gossip-store to force compaction. */
|
|
bool gossip_store_compact(struct gossip_store *gs);
|
|
|
|
/**
|
|
* Get a readonly fd for the gossip_store.
|
|
* @gs: the gossip store.
|
|
*
|
|
* Returns -1 on failure, and sets errno.
|
|
*/
|
|
int gossip_store_readonly_fd(struct gossip_store *gs);
|
|
|
|
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_H */
|