broadcast: don't reorder channel_announce when we get the real one.

If channel_announce is rebroadcast, it should replace the existing one
in-place.  We currently only do this if we start from the unsigned one
and replace it with the signed one when we hit 6 confirms.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-12-21 13:13:24 +10:30
committed by Christian Decker
parent 425143646c
commit f293ff0a6a
6 changed files with 49 additions and 19 deletions

View File

@@ -565,6 +565,9 @@ bool handle_channel_announcement(
c1 = get_connection_by_scid(rstate, &short_channel_id, 1);
forward = !c0 || !c1 || !c0->channel_announcement || !c1->channel_announcement;
/* FIXME: What should we do if this channel_announce is completely
* different from previous? eg. different nodes? We would have to
* clear out the old announce and all updates... */
add_channel_direction(rstate, &node_id_1, &node_id_2, &short_channel_id,
sigfail ? NULL : serialized);
add_channel_direction(rstate, &node_id_2, &node_id_1, &short_channel_id,
@@ -581,7 +584,7 @@ bool handle_channel_announcement(
u8 *tag = tal_arr(tmpctx, u8, 0);
towire_short_channel_id(&tag, &short_channel_id);
queue_broadcast(rstate->broadcasts, WIRE_CHANNEL_ANNOUNCEMENT,
tag, serialized);
tag, serialized, true);
tal_free(tmpctx);
return local;
@@ -677,7 +680,7 @@ void handle_channel_update(struct routing_state *rstate, const u8 *update)
queue_broadcast(rstate->broadcasts,
WIRE_CHANNEL_UPDATE,
tag,
serialized);
serialized, false);
tal_free(c->channel_update);
c->channel_update = tal_steal(c, serialized);
@@ -783,7 +786,8 @@ void handle_node_announcement(
queue_broadcast(rstate->broadcasts,
WIRE_NODE_ANNOUNCEMENT,
tag,
serialized);
serialized,
false);
tal_free(node->node_announcement);
node->node_announcement = tal_steal(node, serialized);
tal_free(tmpctx);