Browse Source

seeker: handle non-synced state internally.

We weren't supposed to do any gossiping until we were synced (and thus
knew blockheight), but our seeker_check() didn't wait for it!  Move the
waiting all into seeker.c, so it can handle it all consistently.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 6 years ago
committed by neil saitug
parent
commit
48f0362eae
  1. 15
      gossipd/gossipd.c
  2. 10
      gossipd/seeker.c

15
gossipd/gossipd.c

@ -577,9 +577,8 @@ 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 (wait until we're synced!). */
if (daemon->current_blockheight)
seeker_setup_peer_gossip(daemon->seeker, peer);
/* This sends the initial timestamp filter. */
seeker_setup_peer_gossip(daemon->seeker, peer);
/* BOLT #7:
*
@ -1241,8 +1240,6 @@ 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);
@ -1263,14 +1260,6 @@ 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)
seeker_setup_peer_gossip(daemon->seeker, peer);
}
return daemon_conn_read_next(conn, daemon->master);
}

10
gossipd/seeker.c

@ -902,9 +902,13 @@ static void seeker_check(struct seeker *seeker)
{
#if DEVELOPER
if (dev_suppress_gossip)
return;
goto out;
#endif
/* We don't do anything until we're synced. */
if (seeker->daemon->current_blockheight == 0)
goto out;
switch (seeker->state) {
case STARTING_UP:
check_firstpeer(seeker);
@ -929,6 +933,7 @@ static void seeker_check(struct seeker *seeker)
break;
}
out:
begin_check_timer(seeker);
}
@ -943,6 +948,9 @@ void seeker_setup_peer_gossip(struct seeker *seeker, struct peer *peer)
if (dev_suppress_gossip)
return;
#endif
/* Don't start gossiping until we're synced. */
if (seeker->daemon->current_blockheight == 0)
return;
switch (seeker->state) {
case STARTING_UP:

Loading…
Cancel
Save