Browse Source

gossipd: don't ask peers for gossip until we're synced with bitcoind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
38124ec287
  1. 15
      gossipd/gossipd.c

15
gossipd/gossipd.c

@ -1653,8 +1653,9 @@ static struct io_plan *connectd_new_peer(struct io_conn *conn,
/* Free peer if conn closed (destroy_peer closes conn if peer freed) */
tal_steal(peer->dc, peer);
/* This sends the initial timestamp filter. */
setup_gossip_range(peer);
/* This sends the initial timestamp filter (wait until we're synced!). */
if (daemon->current_blockheight)
setup_gossip_range(peer);
/* BOLT #7:
*
@ -2360,6 +2361,8 @@ static struct io_plan *new_blockheight(struct io_conn *conn,
struct daemon *daemon,
const u8 *msg)
{
bool was_unknown = (daemon->current_blockheight == 0);
if (!fromwire_gossip_new_blockheight(msg, &daemon->current_blockheight))
master_badmsg(WIRE_GOSSIP_NEW_BLOCKHEIGHT, msg);
@ -2380,6 +2383,14 @@ static struct io_plan *new_blockheight(struct io_conn *conn,
i--;
}
/* Do we need to start gossip filtering now? */
if (was_unknown) {
struct peer *peer;
list_for_each(&daemon->peers, peer, list)
setup_gossip_range(peer);
}
return daemon_conn_read_next(conn, daemon->master);
}

Loading…
Cancel
Save