mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-04 11:08:03 +01:00
gossipd: send all gossip msgs directly to connectd, not peer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
d7cf38a80a
commit
797da4805f
4 changed files with 28 additions and 12 deletions
|
@ -125,8 +125,8 @@ void queue_peer_msg(struct peer *peer, const u8 *msg TAKES)
|
||||||
u8 *outermsg = towire_gossipd_send_gossip(NULL, &peer->id, msg);
|
u8 *outermsg = towire_gossipd_send_gossip(NULL, &peer->id, msg);
|
||||||
daemon_conn_send(peer->daemon->connectd2, take(outermsg));
|
daemon_conn_send(peer->daemon->connectd2, take(outermsg));
|
||||||
|
|
||||||
/* FIXME: backwards compat! */
|
if (taken(msg))
|
||||||
daemon_conn_send(peer->dc, msg);
|
tal_free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ We have a helper for messages from the store. */
|
/*~ We have a helper for messages from the store. */
|
||||||
|
@ -798,11 +798,10 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn,
|
||||||
list_add_tail(&peer->daemon->peers, &peer->list);
|
list_add_tail(&peer->daemon->peers, &peer->list);
|
||||||
tal_add_destructor(peer, destroy_peer);
|
tal_add_destructor(peer, destroy_peer);
|
||||||
|
|
||||||
/* This is the new connection: calls maybe_send_query_responses when
|
/* This is the new connection. */
|
||||||
* nothing else to send. */
|
|
||||||
peer->dc = daemon_conn_new(daemon, fds[0],
|
peer->dc = daemon_conn_new(daemon, fds[0],
|
||||||
peer_msg_in,
|
peer_msg_in,
|
||||||
maybe_send_query_responses, peer);
|
NULL, peer);
|
||||||
/* Free peer if conn closed (destroy_peer closes conn if peer freed) */
|
/* Free peer if conn closed (destroy_peer closes conn if peer freed) */
|
||||||
tal_steal(peer->dc, peer);
|
tal_steal(peer->dc, peer);
|
||||||
|
|
||||||
|
@ -1157,7 +1156,8 @@ static void gossip_init(struct daemon *daemon, const u8 *msg)
|
||||||
|
|
||||||
/* connectd is already started, and uses this fd to ask us things. */
|
/* connectd is already started, and uses this fd to ask us things. */
|
||||||
daemon->connectd = daemon_conn_new(daemon, CONNECTD_FD,
|
daemon->connectd = daemon_conn_new(daemon, CONNECTD_FD,
|
||||||
connectd_req, NULL, daemon);
|
connectd_req,
|
||||||
|
maybe_send_query_responses, daemon);
|
||||||
|
|
||||||
daemon->connectd2 = daemon_conn_new(daemon, CONNECTD2_FD,
|
daemon->connectd2 = daemon_conn_new(daemon, CONNECTD2_FD,
|
||||||
connectd_gossip_req, NULL, daemon);
|
connectd_gossip_req, NULL, daemon);
|
||||||
|
|
|
@ -335,8 +335,8 @@ const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg)
|
||||||
peer->scid_query_idx = 0;
|
peer->scid_query_idx = 0;
|
||||||
peer->scid_query_nodes = tal_arr(peer, struct node_id, 0);
|
peer->scid_query_nodes = tal_arr(peer, struct node_id, 0);
|
||||||
|
|
||||||
/* Notify the daemon_conn-write loop to invoke create_next_scid_reply */
|
/* Notify the daemon_conn-write loop to invoke maybe_send_query_responses_peer */
|
||||||
daemon_conn_wake(peer->dc);
|
daemon_conn_wake(peer->daemon->connectd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ static void uniquify_node_ids(struct node_id **ids)
|
||||||
/* We are fairly careful to avoid the peer DoSing us with channel queries:
|
/* We are fairly careful to avoid the peer DoSing us with channel queries:
|
||||||
* this routine sends information about a single short_channel_id, unless
|
* this routine sends information about a single short_channel_id, unless
|
||||||
* it's finished all of them. */
|
* it's finished all of them. */
|
||||||
void maybe_send_query_responses(struct peer *peer)
|
static bool maybe_send_query_responses_peer(struct peer *peer)
|
||||||
{
|
{
|
||||||
struct routing_state *rstate = peer->daemon->rstate;
|
struct routing_state *rstate = peer->daemon->rstate;
|
||||||
size_t i, num;
|
size_t i, num;
|
||||||
|
@ -1119,6 +1119,22 @@ void maybe_send_query_responses(struct peer *peer)
|
||||||
peer->scid_query_nodes = tal_free(peer->scid_query_nodes);
|
peer->scid_query_nodes = tal_free(peer->scid_query_nodes);
|
||||||
peer->scid_query_nodes_idx = 0;
|
peer->scid_query_nodes_idx = 0;
|
||||||
}
|
}
|
||||||
|
return sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void maybe_send_query_responses(struct daemon *daemon)
|
||||||
|
{
|
||||||
|
/* Rotate through, so we don't favor a single peer. */
|
||||||
|
struct list_head used;
|
||||||
|
struct peer *p;
|
||||||
|
|
||||||
|
list_head_init(&used);
|
||||||
|
while ((p = list_pop(&daemon->peers, struct peer, list)) != NULL) {
|
||||||
|
list_add(&used, &p->list);
|
||||||
|
if (maybe_send_query_responses_peer(p))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
list_append_list(&daemon->peers, &used);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool query_channel_range(struct daemon *daemon,
|
bool query_channel_range(struct daemon *daemon,
|
||||||
|
|
|
@ -16,8 +16,8 @@ const u8 *handle_reply_short_channel_ids_end(struct peer *peer, const u8 *msg);
|
||||||
const u8 *handle_query_channel_range(struct peer *peer, const u8 *msg);
|
const u8 *handle_query_channel_range(struct peer *peer, const u8 *msg);
|
||||||
const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg);
|
const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg);
|
||||||
|
|
||||||
/* This called when the peer is idle. */
|
/* This called when the connectd is idle. */
|
||||||
void maybe_send_query_responses(struct peer *peer);
|
void maybe_send_query_responses(struct daemon *daemon);
|
||||||
|
|
||||||
/* BOLT #7:
|
/* BOLT #7:
|
||||||
*
|
*
|
||||||
|
|
|
@ -210,7 +210,7 @@ void master_badmsg(u32 type_expected UNNEEDED, const u8 *msg)
|
||||||
void maybe_send_own_node_announce(struct daemon *daemon UNNEEDED, bool startup UNNEEDED)
|
void maybe_send_own_node_announce(struct daemon *daemon UNNEEDED, bool startup UNNEEDED)
|
||||||
{ fprintf(stderr, "maybe_send_own_node_announce called!\n"); abort(); }
|
{ fprintf(stderr, "maybe_send_own_node_announce called!\n"); abort(); }
|
||||||
/* Generated stub for maybe_send_query_responses */
|
/* Generated stub for maybe_send_query_responses */
|
||||||
void maybe_send_query_responses(struct peer *peer UNNEEDED)
|
void maybe_send_query_responses(struct daemon *daemon UNNEEDED)
|
||||||
{ fprintf(stderr, "maybe_send_query_responses called!\n"); abort(); }
|
{ fprintf(stderr, "maybe_send_query_responses called!\n"); abort(); }
|
||||||
/* Generated stub for memleak_find_allocations */
|
/* Generated stub for memleak_find_allocations */
|
||||||
struct htable *memleak_find_allocations(const tal_t *ctx UNNEEDED,
|
struct htable *memleak_find_allocations(const tal_t *ctx UNNEEDED,
|
||||||
|
|
Loading…
Add table
Reference in a new issue