multi: start asking for update timestamps in QueryChannelRange

This commit also adds a new `protocol.no-timestamp-query-option` option
to disable the new behaviour.
This commit is contained in:
Elle Mouton
2023-09-20 09:34:21 +02:00
parent 893147d83e
commit a439cc970f
9 changed files with 72 additions and 11 deletions

View File

@@ -271,6 +271,11 @@ type gossipSyncerCfg struct {
// peer.
noReplyQueries bool
// noTimestampQueryOption will prevent the GossipSyncer from querying
// timestamps of announcement messages from the peer, and it will
// prevent it from responding to timestamp queries.
noTimestampQueryOption bool
// ignoreHistoricalFilters will prevent syncers from replying with
// historical data when the remote peer sets a gossip_timestamp_range.
// This prevents ranges with old start times from causing us to dump the
@@ -922,7 +927,7 @@ func (g *GossipSyncer) genChanRangeQuery(
case newestChan.BlockHeight <= chanRangeQueryBuffer:
startHeight = 0
default:
startHeight = uint32(newestChan.BlockHeight - chanRangeQueryBuffer)
startHeight = newestChan.BlockHeight - chanRangeQueryBuffer
}
// Determine the number of blocks to request based on our best height.
@@ -945,6 +950,11 @@ func (g *GossipSyncer) genChanRangeQuery(
FirstBlockHeight: startHeight,
NumBlocks: numBlocks,
}
if !g.cfg.noTimestampQueryOption {
query.QueryOptions = lnwire.NewTimestampQueryOption()
}
g.curQueryRangeMsg = query
return query, nil