2018-03-26 10:35:34 +10:30
|
|
|
#ifndef LIGHTNING_GOSSIPD_GOSSIP_STORE_H
|
|
|
|
#define LIGHTNING_GOSSIPD_GOSSIP_STORE_H
|
2018-03-13 12:08:03 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-03-28 12:54:09 +02:00
|
|
|
#include <bitcoin/short_channel_id.h>
|
2021-09-16 14:30:42 +09:30
|
|
|
#include <ccan/list/list.h>
|
2018-03-13 12:08:03 +01:00
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#include <ccan/tal/tal.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gossip_store -- On-disk storage related information
|
|
|
|
*/
|
2018-08-30 09:34:28 +09:30
|
|
|
|
2018-03-13 12:08:03 +01:00
|
|
|
struct gossip_store;
|
2024-01-31 15:03:11 +10:30
|
|
|
struct broadcastable;
|
|
|
|
struct daemon;
|
2018-03-23 17:34:11 +01:00
|
|
|
struct routing_state;
|
2018-03-13 12:08:03 +01:00
|
|
|
|
2024-01-31 14:56:33 +10:30
|
|
|
struct gossip_store *gossip_store_new(struct daemon *daemon);
|
2018-03-13 12:08:03 +01:00
|
|
|
|
|
|
|
/**
|
2018-04-11 08:33:35 +09:30
|
|
|
* Load the initial gossip store, if any.
|
2018-03-13 12:08:03 +01:00
|
|
|
*
|
|
|
|
* @param gs The `gossip_store` to read from
|
2019-06-12 08:55:07 +09:30
|
|
|
*
|
2019-10-08 11:41:24 +10:30
|
|
|
* Returns the last-modified time of the store, or 0 if it was created new.
|
2018-03-13 12:08:03 +01:00
|
|
|
*/
|
2024-01-31 14:56:33 +10:30
|
|
|
u32 gossip_store_load(struct gossip_store *gs);
|
2018-03-13 12:08:03 +01:00
|
|
|
|
2018-03-23 17:34:11 +01:00
|
|
|
/**
|
2019-05-17 05:25:17 +09:30
|
|
|
* Add a gossip message to the gossip_store (and optional addendum)
|
2019-11-04 11:07:05 +10:30
|
|
|
* @gs: gossip store
|
|
|
|
* @gossip_msg: the gossip message to insert.
|
|
|
|
* @timestamp: the timestamp for filtering of this messsage.
|
2023-07-22 20:49:23 +09:30
|
|
|
* @dying: true if this message is for a dying channel.
|
2019-11-04 11:07:05 +10:30
|
|
|
* @addendum: another message to append immediately after this
|
|
|
|
* (for appending amounts to channel_announcements for internal use).
|
2018-03-23 17:34:11 +01:00
|
|
|
*/
|
2019-05-04 15:23:12 +09:30
|
|
|
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg,
|
2024-01-31 15:03:11 +10:30
|
|
|
u32 timestamp, bool dying,
|
2022-12-16 10:25:47 -06:00
|
|
|
const u8 *addendum);
|
2019-05-17 05:25:17 +09:30
|
|
|
|
2018-03-25 18:23:10 +02:00
|
|
|
|
2024-01-31 14:49:33 +10:30
|
|
|
/**
|
|
|
|
* Delete the record at this offset (offset is that of
|
|
|
|
* record, not header, unlike bcast->index!).
|
|
|
|
*
|
|
|
|
* In developer mode, checks that type is correct.
|
|
|
|
*/
|
|
|
|
void gossip_store_del(struct gossip_store *gs,
|
|
|
|
u64 offset,
|
|
|
|
int type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a flag the record at this offset (offset is that of
|
|
|
|
* record, not header, unlike bcast->index!).
|
|
|
|
*
|
|
|
|
* In developer mode, checks that type is correct.
|
|
|
|
*/
|
|
|
|
void gossip_store_flag(struct gossip_store *gs,
|
|
|
|
u64 offset,
|
|
|
|
u16 flag,
|
|
|
|
int type);
|
|
|
|
|
2020-08-11 14:36:56 +09:30
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2024-01-31 14:49:33 +10:30
|
|
|
/**
|
|
|
|
* Direct store accessor: get timestamp header for a record.
|
|
|
|
*
|
|
|
|
* Offset is *after* the header.
|
|
|
|
*/
|
|
|
|
u32 gossip_store_get_timestamp(struct gossip_store *gs, u64 offset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Direct store accessor: set timestamp header for a record.
|
|
|
|
*
|
|
|
|
* Offset is *after* the header.
|
|
|
|
*/
|
|
|
|
void gossip_store_set_timestamp(struct gossip_store *gs, u64 offset, u32 timestamp);
|
|
|
|
|
2018-03-26 10:35:34 +10:30
|
|
|
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_H */
|