mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
gossip: Use replace_broadcast when enqueuing a channel_announcement
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
01b7e2a7c0
commit
26b5588656
@ -50,6 +50,16 @@ struct pending_cannouncement {
|
||||
const u8 *updates[2];
|
||||
};
|
||||
|
||||
/**
|
||||
* routing_channel keeps track of the indices in the broadcast queue
|
||||
* for the corresponding messages. This way we always know exactly
|
||||
* which broadcast to replace, and don't have to search for it */
|
||||
enum gossip_msg_indexes {
|
||||
MSG_INDEX_CUPDATE_0,
|
||||
MSG_INDEX_CUPDATE_1,
|
||||
MSG_INDEX_CANNOUNCE
|
||||
};
|
||||
|
||||
static struct node_map *empty_node_map(const tal_t *ctx)
|
||||
{
|
||||
struct node_map *map = tal(ctx, struct node_map);
|
||||
@ -564,6 +574,7 @@ routing_channel_new(const tal_t *ctx, struct short_channel_id *scid)
|
||||
chan->nodes[0] = chan->nodes[1] = NULL;
|
||||
chan->txout_script = NULL;
|
||||
chan->state = TXOUT_FETCHING;
|
||||
memset(&chan->msg_indexes, 0, sizeof(chan->msg_indexes));
|
||||
return chan;
|
||||
}
|
||||
|
||||
@ -677,6 +688,11 @@ bool handle_pending_cannouncement(struct routing_state *rstate,
|
||||
u8 *tag;
|
||||
const u8 *s;
|
||||
struct pending_cannouncement *pending;
|
||||
struct routing_channel *chan;
|
||||
u64 uscid = short_channel_id_to_uint(scid);
|
||||
|
||||
chan = uintmap_get(&rstate->channels, uscid);
|
||||
assert(chan);
|
||||
|
||||
pending = find_pending_cannouncement(rstate, scid);
|
||||
assert(pending);
|
||||
@ -732,9 +748,10 @@ bool handle_pending_cannouncement(struct routing_state *rstate,
|
||||
&pending->short_channel_id, pending->announce);
|
||||
|
||||
if (forward) {
|
||||
if (queue_broadcast(rstate->broadcasts,
|
||||
WIRE_CHANNEL_ANNOUNCEMENT,
|
||||
tag, pending->announce))
|
||||
if (replace_broadcast(rstate->broadcasts,
|
||||
&chan->msg_indexes[MSG_INDEX_CANNOUNCE],
|
||||
WIRE_CHANNEL_ANNOUNCEMENT,
|
||||
(u8*)tag, pending->announce))
|
||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||
"Announcement %s was replaced?",
|
||||
tal_hex(trc, pending->announce));
|
||||
|
@ -94,6 +94,8 @@ struct routing_channel {
|
||||
|
||||
struct node_connection *connections[2];
|
||||
struct node *nodes[2];
|
||||
|
||||
u64 msg_indexes[3];
|
||||
};
|
||||
|
||||
struct routing_state {
|
||||
|
@ -75,6 +75,13 @@ bool queue_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||
const u8 *tag UNNEEDED,
|
||||
const u8 *payload UNNEEDED)
|
||||
{ fprintf(stderr, "queue_broadcast called!\n"); abort(); }
|
||||
/* Generated stub for replace_broadcast */
|
||||
bool replace_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||
u64 *index UNNEEDED,
|
||||
const int type UNNEEDED,
|
||||
const u8 *tag UNNEEDED,
|
||||
const u8 *payload UNNEEDED)
|
||||
{ fprintf(stderr, "replace_broadcast called!\n"); abort(); }
|
||||
/* Generated stub for status_failed */
|
||||
void status_failed(enum status_fail code UNNEEDED, const char *fmt UNNEEDED, ...)
|
||||
{ fprintf(stderr, "status_failed called!\n"); abort(); }
|
||||
|
@ -46,6 +46,13 @@ bool queue_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||
const u8 *tag UNNEEDED,
|
||||
const u8 *payload UNNEEDED)
|
||||
{ fprintf(stderr, "queue_broadcast called!\n"); abort(); }
|
||||
/* Generated stub for replace_broadcast */
|
||||
bool replace_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||
u64 *index UNNEEDED,
|
||||
const int type UNNEEDED,
|
||||
const u8 *tag UNNEEDED,
|
||||
const u8 *payload UNNEEDED)
|
||||
{ fprintf(stderr, "replace_broadcast called!\n"); abort(); }
|
||||
/* Generated stub for status_failed */
|
||||
void status_failed(enum status_fail code UNNEEDED, const char *fmt UNNEEDED, ...)
|
||||
{ fprintf(stderr, "status_failed called!\n"); abort(); }
|
||||
|
@ -39,6 +39,13 @@ bool queue_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||
const u8 *tag UNNEEDED,
|
||||
const u8 *payload UNNEEDED)
|
||||
{ fprintf(stderr, "queue_broadcast called!\n"); abort(); }
|
||||
/* Generated stub for replace_broadcast */
|
||||
bool replace_broadcast(struct broadcast_state *bstate UNNEEDED,
|
||||
u64 *index UNNEEDED,
|
||||
const int type UNNEEDED,
|
||||
const u8 *tag UNNEEDED,
|
||||
const u8 *payload UNNEEDED)
|
||||
{ fprintf(stderr, "replace_broadcast called!\n"); abort(); }
|
||||
/* Generated stub for status_failed */
|
||||
void status_failed(enum status_fail code UNNEEDED, const char *fmt UNNEEDED, ...)
|
||||
{ fprintf(stderr, "status_failed called!\n"); abort(); }
|
||||
|
Loading…
Reference in New Issue
Block a user