From 483abbee5b0097528957424389854c6dd358c700 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 20 Dec 2017 14:02:04 +0100 Subject: [PATCH] discovery: make sure ChannelUpdates always have incremented timestamp This commit ensures that we always increment the timestamp of ChannelUpdates we send telling the network about changes to our channel policy. We do this because it could happen (especially during tests) that we issued an update, but the ChannelUpdate would have the same timestamp as our last ChannelUpdate, and would be ignored by the network. --- discovery/gossiper.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index bf8762574..4dedfae2f 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1986,12 +1986,18 @@ func (d *AuthenticatedGossiper) sendAnnSigReliably( func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo, edge *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement, *lnwire.ChannelUpdate, error) { - edge.LastUpdate = time.Now() + // Make sure timestamp is always increased, such that our update + // gets propagated. + timestamp := time.Now().Unix() + if timestamp <= edge.LastUpdate.Unix() { + timestamp = edge.LastUpdate.Unix() + 1 + } + edge.LastUpdate = time.Unix(timestamp, 0) chanUpdate := &lnwire.ChannelUpdate{ Signature: edge.Signature, ChainHash: info.ChainHash, ShortChannelID: lnwire.NewShortChanIDFromInt(edge.ChannelID), - Timestamp: uint32(edge.LastUpdate.Unix()), + Timestamp: uint32(timestamp), Flags: edge.Flags, TimeLockDelta: edge.TimeLockDelta, HtlcMinimumMsat: edge.MinHTLC,