From be5d945e9713dd966f9f70e09ae1f56949816242 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Feb 2018 06:53:13 +1030 Subject: [PATCH] gossip: only send out gossip to non-local peers when we're supposed to. This hook is called when the queue is empty; we should only send gossip according to the gossip timer. We're currently dribbling it out after every message, in violation of the spec. Signed-off-by: Rusty Russell --- gossipd/gossip.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 0f90343d7..2429bc8a5 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -901,10 +901,16 @@ static struct io_plan *nonlocal_dump_gossip(struct io_conn *conn, struct daemon_ /* Make sure we are not connected directly */ assert(!peer->local); + /* Nothing to do if we're not gossiping */ + if (!peer->gossip_sync) + return msg_queue_wait(conn, &peer->remote->out, + daemon_conn_write_next, dc); + next = next_broadcast_message(peer->daemon->rstate->broadcasts, peer->broadcast_index); if (!next) { + peer->gossip_sync = false; return msg_queue_wait(conn, &peer->remote->out, daemon_conn_write_next, dc); } else {