mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
gossip: Prevent normal messages to trigger the staggered broadcast
Only call `peer_dump_gossip` if the broadcast timer actually expired. previously it could get triggered by any normal message.
This commit is contained in:
parent
fccab6411d
commit
8912272983
1 changed files with 12 additions and 4 deletions
|
@ -60,6 +60,8 @@ struct peer {
|
||||||
/* High water mark for the staggered broadcast */
|
/* High water mark for the staggered broadcast */
|
||||||
u64 broadcast_index;
|
u64 broadcast_index;
|
||||||
u8 **msg_out;
|
u8 **msg_out;
|
||||||
|
/* Is it time to continue the staggered broadcast? */
|
||||||
|
bool gossip_sync;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void destroy_peer(struct peer *peer)
|
static void destroy_peer(struct peer *peer)
|
||||||
|
@ -158,11 +160,12 @@ static struct io_plan *pkt_out(struct io_conn *conn, struct peer *peer);
|
||||||
|
|
||||||
/* Wake up the outgoing direction of the connection and write any
|
/* Wake up the outgoing direction of the connection and write any
|
||||||
* queued messages. Needed since the `io_wake` method signature does
|
* queued messages. Needed since the `io_wake` method signature does
|
||||||
* not allow us to specify it as the callback for `new_reltimer`.
|
* not allow us to specify it as the callback for `new_reltimer`, but
|
||||||
|
* it allows us to set an additional flag for the routing dump..
|
||||||
*/
|
*/
|
||||||
static void wake_pkt_out(struct peer *peer)
|
static void wake_pkt_out(struct peer *peer)
|
||||||
{
|
{
|
||||||
/* */
|
peer->gossip_sync = true;
|
||||||
io_wake(peer);
|
io_wake(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +199,13 @@ static struct io_plan *pkt_out(struct io_conn *conn, struct peer *peer)
|
||||||
return peer_write_message(conn, peer->cs, out, pkt_out);
|
return peer_write_message(conn, peer->cs, out, pkt_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send any queued up broadcast messages */
|
if (peer->gossip_sync){
|
||||||
return peer_dump_gossip(conn, peer);
|
/* Send any queued up broadcast messages */
|
||||||
|
peer->gossip_sync = false;
|
||||||
|
return peer_dump_gossip(conn, peer);
|
||||||
|
} else {
|
||||||
|
return io_out_wait(conn, peer, pkt_out, peer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool has_even_bit(const u8 *bitmap)
|
static bool has_even_bit(const u8 *bitmap)
|
||||||
|
|
Loading…
Add table
Reference in a new issue