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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-05-18 20:50:28 +09:30 committed by Christian Decker
parent 85a062164a
commit adbe02c6be

View File

@ -4,6 +4,7 @@
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
#include <ccan/endian/endian.h>
#include <ccan/mem/mem.h>
#include <ccan/structeq/structeq.h>
#include <ccan/tal/str/str.h>
#include <common/features.h>
@ -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;
}