mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 02:27:51 +01:00
b8285db263
We tal_dup_arr() it, which does take. Make it const in the structure; the tal_dup_arr() removes the const, so it compiles without it, but it's misleading. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
#ifndef LIGHTNING_LIGHTNINGD_GOSSIP_BROADCAST_H
|
|
#define LIGHTNING_LIGHTNINGD_GOSSIP_BROADCAST_H
|
|
#include "config.h"
|
|
|
|
#include <ccan/intmap/intmap.h>
|
|
#include <ccan/list/list.h>
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <ccan/tal/tal.h>
|
|
|
|
/* 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;
|
|
};
|
|
|
|
struct broadcast_state *new_broadcast_state(tal_t *ctx);
|
|
|
|
/* Replace a queued message with @index, if it matches the type and
|
|
* tag for the new message. The new message will be queued with the
|
|
* next highest index. @index is updated to hold the index of the
|
|
* newly queued message*/
|
|
bool replace_broadcast(const tal_t *ctx,
|
|
struct broadcast_state *bstate,
|
|
u64 *index,
|
|
const u8 *payload TAKES);
|
|
|
|
|
|
struct queued_message *next_broadcast_message(struct broadcast_state *bstate, u64 last_index);
|
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_GOSSIP_BROADCAST_H */
|