From adbe02c6befeae8db5d1892c63d3701ac8cff421 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 18 May 2018 20:50:28 +0930 Subject: [PATCH] gossip: temporarily allow replacement of updates with same timestamp. We erroneously create updates with the same timestamps when tests run quickly, and the second one is ignored. We've already noted that this should be fixed: gossipd should generate all the updates, as it already has to do the case where channeld crashed, for example. But that's a bigger change. Signed-off-by: Rusty Russell --- gossipd/routing.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index 2d7e87a9b..4a51e63c7 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -875,7 +876,10 @@ static void update_pending(struct pending_cannouncement *pending, type_to_string(tmpctx, struct short_channel_id, &pending->short_channel_id), direction); - if (pending->update_timestamps[direction] < timestamp) { + /* FIXME: This should be <, but in our tests we sometimes can generate + * more than one update per second, and we don't coordinate timestamps + * between gossipd and channeld. */ + if (pending->update_timestamps[direction] <= timestamp) { if (pending->updates[direction]) { status_trace("Replacing existing update"); tal_free(pending->updates[direction]); @@ -1037,7 +1041,14 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update, c = &chan->half[direction]; - if (is_halfchan_defined(c) && c->last_timestamp >= timestamp) { + /* FIXME: This should be >=, but in our tests we sometimes can generate + * more than one update per second, and we don't coordinate timestamps + * between gossipd and channeld. But don't update just because of + * re-transmissions, either. */ + if (is_halfchan_defined(c) + && (c->last_timestamp > timestamp + || memeq(c->channel_update, tal_len(c->channel_update), + serialized, tal_len(serialized)))) { SUPERVERBOSE("Ignoring outdated update."); return NULL; }