2018-03-26 01:05:34 +01:00
|
|
|
#ifndef LIGHTNING_GOSSIPD_GOSSIP_STORE_H
|
|
|
|
#define LIGHTNING_GOSSIPD_GOSSIP_STORE_H
|
2018-03-13 11:08:03 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-03-28 11:54:09 +01:00
|
|
|
#include <bitcoin/short_channel_id.h>
|
2018-03-13 11:08:03 +00:00
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#include <ccan/tal/tal.h>
|
2018-03-23 16:34:11 +00:00
|
|
|
#include <gossipd/routing.h>
|
2018-03-13 11:08:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gossip_store -- On-disk storage related information
|
|
|
|
*/
|
2018-09-21 01:31:45 +01:00
|
|
|
#define GOSSIP_STORE_VERSION 3
|
2018-08-30 01:04:28 +01:00
|
|
|
|
2019-04-10 08:31:29 +01:00
|
|
|
struct broadcast_state;
|
2018-03-13 11:08:03 +00:00
|
|
|
struct gossip_store;
|
2018-03-23 16:34:11 +00:00
|
|
|
struct routing_state;
|
2018-03-13 11:08:03 +00:00
|
|
|
|
2019-04-10 08:31:29 +01:00
|
|
|
struct gossip_store *gossip_store_new(struct routing_state *rstate);
|
2018-03-13 11:08:03 +00:00
|
|
|
|
|
|
|
/**
|
2018-04-11 00:03:35 +01:00
|
|
|
* Load the initial gossip store, if any.
|
2018-03-13 11:08:03 +00:00
|
|
|
*
|
2018-04-11 00:03:35 +01:00
|
|
|
* @param rstate The routing state to load init.
|
2018-03-13 11:08:03 +00:00
|
|
|
* @param gs The `gossip_store` to read from
|
|
|
|
*/
|
2018-04-11 00:03:35 +01:00
|
|
|
void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs);
|
2018-03-13 11:08:03 +00:00
|
|
|
|
2018-03-23 16:34:11 +00:00
|
|
|
/**
|
2018-05-30 19:29:17 +01:00
|
|
|
* Add a gossip message to the gossip_store
|
2018-03-23 16:34:11 +00:00
|
|
|
*/
|
2019-04-10 08:31:29 +01:00
|
|
|
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg);
|
2018-03-25 17:23:10 +01:00
|
|
|
|
2018-03-28 11:54:09 +01:00
|
|
|
/**
|
|
|
|
* Remember that we deleted a channel as a result of its outpoint being spent
|
|
|
|
*/
|
|
|
|
void gossip_store_add_channel_delete(struct gossip_store *gs,
|
|
|
|
const struct short_channel_id *scid);
|
|
|
|
|
2019-04-10 08:31:29 +01:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2019-04-10 08:31:29 +01:00
|
|
|
/**
|
|
|
|
* If we need to compact the gossip store, do so.
|
|
|
|
* @gs: the gossip store.
|
|
|
|
* @bs: a pointer to the broadcast state: replaced if we compact it.
|
|
|
|
*/
|
|
|
|
void gossip_store_maybe_compact(struct gossip_store *gs,
|
|
|
|
struct broadcast_state **bs);
|
|
|
|
|
|
|
|
|
|
|
|
/* Expose for dev-compact-gossip-store to force compaction. */
|
|
|
|
bool gossip_store_compact(struct gossip_store *gs,
|
|
|
|
struct broadcast_state **bs);
|
2018-03-26 01:05:34 +01:00
|
|
|
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_H */
|