mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
7ede5aac31
Save some overhead, plus gets us ready for giving subdaemons direct store access. This is the first time we *upgrade* the gossip_store, rather than just discarding. The downside is that we need to add an extra message after each channel_announcement, containing the channel capacity. After: store_load_msec:28337-30288(28975+/-7.4e+02) vsz_kb:582304-582316(582306+/-4.8) store_rewrite_sec:11.240000-11.800000(11.55+/-0.21) listnodes_sec:1.800000-1.880000(1.84+/-0.028) listchannels_sec:22.690000-26.260000(23.878+/-1.3) routing_sec:2.280000-9.570000(6.842+/-2.8) peer_write_all_sec:48.160000-51.480000(49.608+/-1.1) Differences: -vsz_kb:582320 +vsz_kb:582316 -listnodes_sec:2.100000-2.170000(2.118+/-0.026) +listnodes_sec:1.800000-1.880000(1.84+/-0.028) -peer_write_all_sec:51.600000-52.550000(52.188+/-0.34) +peer_write_all_sec:48.160000-51.480000(49.608+/-1.1) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
71 lines
1.8 KiB
C
71 lines
1.8 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/short_types/short_types.h>
|
|
#include <ccan/tal/tal.h>
|
|
#include <gossipd/routing.h>
|
|
|
|
/**
|
|
* gossip_store -- On-disk storage related information
|
|
*/
|
|
#define GOSSIP_STORE_VERSION 4
|
|
|
|
struct broadcast_state;
|
|
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
|
|
*/
|
|
void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs);
|
|
|
|
/**
|
|
* Add a gossip message to the gossip_store
|
|
*/
|
|
u64 gossip_store_add(struct gossip_store *gs, const u8 *gossip_msg);
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/**
|
|
* 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.
|
|
* @offset: the change in the store, if any.
|
|
*
|
|
* If @offset is non-zero on return, caller must update peers.
|
|
*/
|
|
void gossip_store_maybe_compact(struct gossip_store *gs,
|
|
struct broadcast_state **bs,
|
|
u32 *offset);
|
|
|
|
|
|
/* Expose for dev-compact-gossip-store to force compaction. */
|
|
bool gossip_store_compact(struct gossip_store *gs,
|
|
struct broadcast_state **bs,
|
|
u32 *offset);
|
|
|
|
/* Callback for when gossip_store indexes move */
|
|
|
|
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_H */
|