mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
gossmap_manage: new file for managing the gossip store.
This is a fair amount of code, but much is taken from the old routing.c, with the difference that this uses common/gossmap instead of our own structures. The interfaces are fairly clear: 1. gossmap_manage_new - allocator 2. gossmap_manage_channel_announcement - handle new channel announcement msg - if too early, keeps it in early map - queues it, asks lightingd about UTXO. 3. gossmap_manage_handle_get_txout_reply - handle response from lightningd for above. 4. gossmap_manage_channel_update - handle channel_update message - may have to wait on pending channel_announcement 5. gossmap_manage_node_announcement - handle node_announcement msg - may have to wait on pending channel_announcement 6. gossmap_manage_new_block - see if early announces can now be processed. 7. gossmap_manage_channel_spent - lightningd tells us UTXO is spent - may prepare channel for closing in 12 blocks. 8. gossmap_manage_channel_dying - gossip_store load tells us channel was spent earlier. - like gossmap_manage_channel_spent, but maybe < 12. 9. gossmap_manage_get_gossmap - gossmap accessor: seeker and queries will need this. 10. gossmap_manage_new_peer - a new peer has connected, give them all our gossip. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
104d6a9c78
commit
1384d56db3
4 changed files with 1192 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <gossipd/gossip_store.h>
|
||||
#include <gossipd/gossip_store_wiregen.h>
|
||||
#include <gossipd/routing.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
#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 broadcastable;
|
||||
struct daemon;
|
||||
struct routing_state;
|
||||
|
||||
struct gossip_store *gossip_store_new(struct daemon *daemon);
|
||||
|
|
1077
gossipd/gossmap_manage.c
Normal file
1077
gossipd/gossmap_manage.c
Normal file
File diff suppressed because it is too large
Load diff
112
gossipd/gossmap_manage.h
Normal file
112
gossipd/gossmap_manage.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
#ifndef LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H
|
||||
#define LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H
|
||||
#include "config.h"
|
||||
|
||||
struct daemon;
|
||||
struct gossmap_manage;
|
||||
|
||||
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)
|
||||
*
|
||||
* Returns an error string if it wasn't redundant or included.
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* 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_channel_dying: dying channel loaded from store.
|
||||
* @gm: the gossmap_manage context
|
||||
* @offset: the offset of the dying marker in the store.
|
||||
* @deadline: the blockheight it is to expire
|
||||
* @scid: the short_channel_id
|
||||
*
|
||||
* Returns false if this channel does not exist (already dead!).
|
||||
*/
|
||||
bool gossmap_manage_channel_dying(struct gossmap_manage *gm,
|
||||
u64 gossmap_offset,
|
||||
u32 deadline,
|
||||
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_new_peer: send all our own gossip to this peer.
|
||||
* @gm: the gossmap_manage context
|
||||
* @peer: the node_id of the peer.
|
||||
*/
|
||||
void gossmap_manage_new_peer(struct gossmap_manage *gm,
|
||||
const struct node_id *peer);
|
||||
|
||||
#endif /* LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H */
|
Loading…
Add table
Reference in a new issue