mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
gossipd: make struct queued_message private.
Callers don't need it, and when we add timestamps it just makes for more places to change. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
#include <ccan/mem/mem.h>
|
||||
#include <gossipd/broadcast.h>
|
||||
|
||||
struct queued_message {
|
||||
/* Broadcast index. */
|
||||
u64 index;
|
||||
|
||||
/* Serialized payload */
|
||||
const u8 *payload;
|
||||
};
|
||||
|
||||
struct broadcast_state *new_broadcast_state(tal_t *ctx)
|
||||
{
|
||||
struct broadcast_state *bstate = tal(ctx, struct broadcast_state);
|
||||
@@ -49,10 +57,14 @@ bool replace_broadcast(const tal_t *ctx,
|
||||
return evicted;
|
||||
}
|
||||
|
||||
struct queued_message *next_broadcast_message(struct broadcast_state *bstate,
|
||||
u64 *last_index)
|
||||
const u8 *next_broadcast(struct broadcast_state *bstate, u64 *last_index)
|
||||
{
|
||||
return uintmap_after(&bstate->broadcasts, last_index);
|
||||
struct queued_message *m;
|
||||
|
||||
m = uintmap_after(&bstate->broadcasts, last_index);
|
||||
if (m)
|
||||
return m->payload;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const u8 *get_broadcast(struct broadcast_state *bstate, u64 msgidx)
|
||||
|
||||
@@ -9,14 +9,6 @@
|
||||
|
||||
/* Common functionality to implement staggered broadcasts with replacement. */
|
||||
|
||||
struct queued_message {
|
||||
/* Broadcast index. */
|
||||
u64 index;
|
||||
|
||||
/* Serialized payload */
|
||||
const u8 *payload;
|
||||
};
|
||||
|
||||
struct broadcast_state {
|
||||
u64 next_index;
|
||||
UINTMAP(struct queued_message *) broadcasts;
|
||||
@@ -34,8 +26,7 @@ bool replace_broadcast(const tal_t *ctx,
|
||||
const u8 *payload TAKES);
|
||||
|
||||
|
||||
struct queued_message *next_broadcast_message(struct broadcast_state *bstate,
|
||||
u64 *last_index);
|
||||
const u8 *next_broadcast(struct broadcast_state *bstate, u64 *last_index);
|
||||
|
||||
const u8 *get_broadcast(struct broadcast_state *bstate, u64 msgidx);
|
||||
#endif /* LIGHTNING_LIGHTNINGD_GOSSIP_BROADCAST_H */
|
||||
|
||||
@@ -708,14 +708,14 @@ static struct io_plan *peer_pkt_out(struct io_conn *conn, struct peer *peer)
|
||||
return ready_for_master(conn, peer);
|
||||
} else if (peer->gossip_sync) {
|
||||
/* If we're supposed to be sending gossip, do so now. */
|
||||
struct queued_message *next;
|
||||
const u8 *next;
|
||||
|
||||
next = next_broadcast_message(peer->daemon->rstate->broadcasts,
|
||||
next = next_broadcast(peer->daemon->rstate->broadcasts,
|
||||
&peer->broadcast_index);
|
||||
|
||||
if (next)
|
||||
return peer_write_message(conn, &peer->local->pcs,
|
||||
next->payload,
|
||||
next,
|
||||
peer_pkt_out);
|
||||
|
||||
/* Gossip is drained. Wait for next timer. */
|
||||
@@ -915,7 +915,7 @@ static bool send_peer_with_fds(struct peer *peer, const u8 *msg)
|
||||
*/
|
||||
static bool nonlocal_dump_gossip(struct io_conn *conn, struct daemon_conn *dc)
|
||||
{
|
||||
struct queued_message *next;
|
||||
const u8 *next;
|
||||
struct peer *peer = dc->ctx;
|
||||
|
||||
|
||||
@@ -926,7 +926,7 @@ static bool nonlocal_dump_gossip(struct io_conn *conn, struct daemon_conn *dc)
|
||||
if (!peer->gossip_sync)
|
||||
return false;
|
||||
|
||||
next = next_broadcast_message(peer->daemon->rstate->broadcasts,
|
||||
next = next_broadcast(peer->daemon->rstate->broadcasts,
|
||||
&peer->broadcast_index);
|
||||
|
||||
if (!next) {
|
||||
@@ -935,7 +935,7 @@ static bool nonlocal_dump_gossip(struct io_conn *conn, struct daemon_conn *dc)
|
||||
} else {
|
||||
u8 *msg = towire_gossip_send_gossip(conn,
|
||||
peer->broadcast_index,
|
||||
next->payload);
|
||||
next);
|
||||
daemon_conn_send(peer->remote, take(msg));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user