mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
ca53c1b699
I had a report of a 0.7.2 user whose node hadn't appeared on 1ml. Their node_announcement wasn't visible to my node, either. I suspect this is a consequence of recent version reducing the amount of gossip they send, as well as large nodes increasingly turning off gossip altogether from some peers (as we do). We should ignore timestamp filters for our own channels: the easiest way to do this is to push them out directly from gossipd (other messages are sent via the store). We change channeld to wrap the local channel_announcements: previously we just handed it to gossipd as for any other gossip message we received from our peer. Now gossipd knows to push it out, as it's local. This interferes with the logic in tests/test_misc.py::test_htlc_send_timeout which expects the node_announcement message last, so we generalize that too. [ Thanks to @trueptolmy for bugfix! ] Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
147 lines
4.4 KiB
C
147 lines
4.4 KiB
C
#ifndef LIGHTNING_GOSSIPD_GOSSIPD_H
|
|
#define LIGHTNING_GOSSIPD_GOSSIPD_H
|
|
#include "config.h"
|
|
#include <bitcoin/block.h>
|
|
#include <ccan/bitmap/bitmap.h>
|
|
#include <ccan/list/list.h>
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <ccan/timer/timer.h>
|
|
#include <common/bigsize.h>
|
|
#include <common/node_id.h>
|
|
|
|
/* We talk to `hsmd` to sign our gossip messages with the node key */
|
|
#define HSM_FD 3
|
|
/* connectd asks us for help finding nodes, and gossip fds for new peers */
|
|
#define CONNECTD_FD 4
|
|
|
|
struct chan;
|
|
struct channel_update_timestamps;
|
|
struct broadcastable;
|
|
struct seeker;
|
|
|
|
/*~ The core daemon structure: */
|
|
struct daemon {
|
|
/* Who am I? Helps us find ourself in the routing map. */
|
|
struct node_id id;
|
|
|
|
/* Peers we are gossiping to: id is unique */
|
|
struct list_head peers;
|
|
|
|
/* Current blockheight: 0 means we're not up-to-date. */
|
|
u32 current_blockheight;
|
|
|
|
/* Connection to lightningd. */
|
|
struct daemon_conn *master;
|
|
|
|
/* Connection to connect daemon. */
|
|
struct daemon_conn *connectd;
|
|
|
|
/* Routing information */
|
|
struct routing_state *rstate;
|
|
|
|
/* chainhash for checking/making gossip msgs */
|
|
struct bitcoin_blkid chain_hash;
|
|
|
|
/* Timers: we batch gossip, and also refresh announcements */
|
|
struct timers timers;
|
|
|
|
/* Features to list in node_announcement. */
|
|
u8 *nodefeatures;
|
|
|
|
/* Alias (not NUL terminated) and favorite color for node_announcement */
|
|
u8 alias[32];
|
|
u8 rgb[3];
|
|
|
|
/* What addresses we can actually announce. */
|
|
struct wireaddr *announcable;
|
|
|
|
/* Timer until we can send a new node_announcement */
|
|
struct oneshot *node_announce_timer;
|
|
|
|
/* Channels we have an announce for, but aren't deep enough. */
|
|
struct short_channel_id *deferred_txouts;
|
|
|
|
/* What, if any, gossip we're seeker from peers. */
|
|
struct seeker *seeker;
|
|
};
|
|
|
|
/* This represents each peer we're gossiping with */
|
|
struct peer {
|
|
/* daemon->peers */
|
|
struct list_node list;
|
|
|
|
/* parent pointer. */
|
|
struct daemon *daemon;
|
|
|
|
/* The ID of the peer (always unique) */
|
|
struct node_id id;
|
|
|
|
/* How much contribution have we made to gossip? */
|
|
size_t gossip_counter;
|
|
|
|
/* The two features gossip cares about (so far) */
|
|
bool gossip_queries_feature, initial_routing_sync_feature;
|
|
|
|
/* Are there outstanding responses for queries on short_channel_ids? */
|
|
const struct short_channel_id *scid_queries;
|
|
const bigsize_t *scid_query_flags;
|
|
size_t scid_query_idx;
|
|
|
|
/* Are there outstanding node_announcements from scid_queries? */
|
|
struct node_id *scid_query_nodes;
|
|
size_t scid_query_nodes_idx;
|
|
|
|
/* Do we have an scid_query outstanding? What to call when it's done? */
|
|
bool scid_query_outstanding;
|
|
void (*scid_query_cb)(struct peer *peer, bool complete);
|
|
|
|
/* How many pongs are we expecting? */
|
|
size_t num_pings_outstanding;
|
|
|
|
/* Map of outstanding channel_range requests. */
|
|
bitmap *query_channel_blocks;
|
|
/* What we're querying: [range_first_blocknum, range_end_blocknum) */
|
|
u32 range_first_blocknum, range_end_blocknum;
|
|
u32 range_blocks_remaining;
|
|
struct short_channel_id *query_channel_scids;
|
|
struct channel_update_timestamps *query_channel_timestamps;
|
|
void (*query_channel_range_cb)(struct peer *peer,
|
|
u32 first_blocknum, u32 number_of_blocks,
|
|
const struct short_channel_id *scids,
|
|
const struct channel_update_timestamps *,
|
|
bool complete);
|
|
|
|
/* The daemon_conn used to queue messages to/from the peer. */
|
|
struct daemon_conn *dc;
|
|
};
|
|
|
|
/* Search for a peer. */
|
|
struct peer *find_peer(struct daemon *daemon, const struct node_id *id);
|
|
|
|
/* This peer (may be NULL) gave is valid gossip. */
|
|
void peer_supplied_good_gossip(struct peer *peer, size_t amount);
|
|
|
|
/* Pick a random peer which passes check_peer */
|
|
struct peer *random_peer(struct daemon *daemon,
|
|
bool (*check_peer)(const struct peer *peer));
|
|
|
|
/* Push this gossip out to all peers immediately. */
|
|
void push_gossip(struct daemon *daemon, const u8 *msg TAKES);
|
|
|
|
/* Queue a gossip message for the peer: the subdaemon on the other end simply
|
|
* forwards it to the peer. */
|
|
void queue_peer_msg(struct peer *peer, const u8 *msg TAKES);
|
|
|
|
/* Queue a gossip_store message for the peer: the subdaemon on the
|
|
* other end simply forwards it to the peer. */
|
|
void queue_peer_from_store(struct peer *peer,
|
|
const struct broadcastable *bcast);
|
|
|
|
/* Reset gossip range for this peer. */
|
|
void setup_gossip_range(struct peer *peer);
|
|
|
|
/* A peer has given us these short channel ids: see if we need to catch up */
|
|
void process_scids(struct daemon *daemon, const struct short_channel_id *scids);
|
|
|
|
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_H */
|