gossipd: track what peer gave us gossip msgs so we can credit it.

Since we have to validate, there can be a delay (and peer might
vanish) between receiving the gossip and actually confirming it, hence
the use of softref.

We will use this information to check that the peers are making progress
as we start asking them for specific information.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-10-08 11:43:24 +10:30
committed by neil saitug
parent d5eca470dc
commit 0091300ee3
12 changed files with 118 additions and 37 deletions

View File

@@ -14,6 +14,8 @@
#include <wire/gen_onion_wire.h>
#include <wire/wire.h>
struct daemon;
struct peer;
struct routing_state;
struct half_chan {
@@ -177,12 +179,17 @@ struct pending_cannouncement {
struct pubkey bitcoin_key_1;
struct pubkey bitcoin_key_2;
/* Automagically turns to NULL of peer freed */
struct peer *peer_softref;
/* The raw bits */
const u8 *announce;
/* Deferred updates, if we received them while waiting for
* this (one for each direction) */
const u8 *updates[2];
/* Peers responsible: turns to NULL if they're freed */
struct peer *update_peer_softref[2];
/* Only ever replace with newer updates */
u32 update_timestamps[2];
@@ -357,14 +364,16 @@ struct chan *new_chan(struct routing_state *rstate,
u8 *handle_channel_announcement(struct routing_state *rstate,
const u8 *announce TAKES,
u32 current_blockheight,
const struct short_channel_id **scid);
const struct short_channel_id **scid,
struct peer *peer);
/**
* handle_pending_cannouncement -- handle channel_announce once we've
* completed short_channel_id lookup. Returns true if handling created
* a new channel.
*/
bool handle_pending_cannouncement(struct routing_state *rstate,
bool handle_pending_cannouncement(struct daemon *daemon,
struct routing_state *rstate,
const struct short_channel_id *scid,
const struct amount_sat sat,
const u8 *txscript);
@@ -378,10 +387,12 @@ struct chan *next_chan(const struct node *node, struct chan_map_iter *i);
* (if not NULL). */
u8 *handle_channel_update(struct routing_state *rstate, const u8 *update TAKES,
const char *source,
struct peer *peer,
struct short_channel_id *unknown_scid);
/* Returns NULL if all OK, otherwise an error for the peer which sent. */
u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node);
u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node,
struct peer *peer);
/* Get a node: use this instead of node_map_get() */
struct node *get_node(struct routing_state *rstate,
@@ -416,11 +427,14 @@ void route_prune(struct routing_state *rstate);
*
* index is usually 0, in which case it's set by insert_broadcast adding it
* to the store.
*
* peer is an optional peer responsible for this.
*/
bool routing_add_channel_announcement(struct routing_state *rstate,
const u8 *msg TAKES,
struct amount_sat sat,
u32 index);
u32 index,
struct peer *peer);
/**
* Add a channel_update without checking for errors
@@ -432,8 +446,8 @@ bool routing_add_channel_announcement(struct routing_state *rstate,
*/
bool routing_add_channel_update(struct routing_state *rstate,
const u8 *update TAKES,
u32 index);
u32 index,
struct peer *peer);
/**
* Add a node_announcement to the network view without checking it
*
@@ -443,7 +457,8 @@ bool routing_add_channel_update(struct routing_state *rstate,
*/
bool routing_add_node_announcement(struct routing_state *rstate,
const u8 *msg TAKES,
u32 index);
u32 index,
struct peer *peer);
/**